如何使用KineticJS绘制动画gif [英] How to draw animated gif with KineticJS

查看:87
本文介绍了如何使用KineticJS绘制动画gif的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用KineticJS绘制动画gif,但是,当我遵循图片教程.有什么方法可以绘制动画gif?

I need to draw animated gif with KineticJS, however, I failed when I followed the image tutorial. Is there any way to draw animated gif?

推荐答案

使用 KineticJS Sprite.

动画GIF是这样做的(非常)古老的方法.它不能很好地工作,在性能方面非常不稳定,并且在不同的浏览器中不一致.当同时显示许多动画GIF时,它也会吃掉内存,并减慢一切.信不信由你,最好用代码而不是在图像文件中处理动画.

Animated GIF is the (very) old way of doing this. It doesn't work very well, it's very flaky performance-wise and inconsistent in different browsers. It also eats memory when lots of animated GIFs are displayed at once and slows everything down. Believe it or not it's better to handle the animation with code instead of within the image file.

我建议使用PNG格式.您应该使用包含所有动画帧的单个PNG文件(精灵表).然后将它们加载到数组中,并使用KineticJS Sprite进行显示.这很简单.您有一个精灵,其中包含您需要的所有内容.这里有一个很好的例子:

I recommend using the PNG format. You should use a single PNG file (sprite sheet) containing all the animation frames together. Then load them into an array and use a KineticJS Sprite to display it. It is fairly straightforward. You have a sprite containing all you need. There is a great example here:

kineticjs动画精灵教程

这篇关于如何使用KineticJS绘制动画gif的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆