微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

为什么在html5中使用canvas进行动画制作?

我是 html5的新手,并且一直在玩画布.我想知道画布什么时候真的有必要/有用吗?即什么时候用它?

如果我需要做简单的动画,比如移动标签,我真的需要画布,还是更好/更容易使用jquery / js?

解决方法

在画布的帮助下,您可以创建2D图形应用程序,动画,图像的简单转换(如旋转它们),GUI等.一些示例:

> Asteroids game
> jigsaw puzzle
>关于GUI,遗憾的是我无法加载网站,不知道为什么……它被称为iWidgets.com,我发现的唯一的东西是screenshot.你可以在那里看到蓝色管道,它们绑定元素.它是在画布的帮助下完成的;在移动元素的同时,管道也在重新绘制;当您更改活动元素时,其所有连接都会将颜色更改为黄色(因此您会看到依赖关系).不错的项目,我希望它暂时无法访问…

关于如何使用它的好文章here

从“An insight into the HTML5 Canvas Element”:

The canvas element is interesting and
worthy of focus because it enables,
for the first time,direct drawing of
graphics within a browser without the
use for an external plugin like Flash
or Java. The beauty of canvas is that
it’s controlled entirely via simple
JavaScript code,meaning it builds on
the powerful functionality JavaScript
already provides and doesn’t require a
crazy learning curve to use.

Choosing to experiment with canvas
over other new elements was simply
down to it’s functionality as a
graphics platform,which inherently
makes it a potentially interesting and
rich platform to play with. It was
decided that pushing the flexible
canvas element would produce the most
interesting results that we can use in
the application.

Another deciding factor for choosing
canvas was to test the animation
capabilities and the possibility of it
being a potential Flash replacement.
Now Flash obvIoUsly has features that
canvas Could never emulate,however
it’s an exciting concept nonetheless
to see exactly what Could be achieved
with canvas that would normally be
done by reaching for Flash.

阅读该文章以获得更多有用的信息

PS.如果您的动画是关于移动的标签(如页面的某些部分),则画布不适合. Canvas用于图形渲染.所以在这种情况下,您将使用jquery或其他JS库.

原文地址:https://www.jb51.cc/html5/168400.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。