Coder Social home page Coder Social logo

tencent / fanvas Goto Github PK

View Code? Open in Web Editor NEW
550.0 37.0 196.0 7.53 MB

Fanvas,一键把swf转为html5 canvas动画。 Fanvas is a tool which can turn flash into canvas animation with just one key!

License: Other

ActionScript 56.84% JavaScript 34.97% HTML 0.68% AngelScript 7.50%

fanvas's Introduction

项目目前是存档状态,感谢您对腾讯开源项目的关注!您可以继续fork后更新迭代,感谢理解和支持;如果您有其他疑问,建议请发送邮件:[email protected] 与我们联系


什么是Fanvas?

Fanvas是一个把swf转为html5 canvas动画的系统,由两部分组成:Actionscript实现的解析器、js运行库。

Flash做动画是最成熟最高效的方式,但由于终端基本不支持Flash播放,这给终端的动画制作带来了不少麻烦。

Fanvas是Flash和Canvas的完美结合,可以把swf(包括矢量和位图)完美地转化为canvas动画,让美术妹子一次制作,到处运行。。。

嘿嘿~~~让美术妹子也搭上H5的快车。

Fanvas的技术难点?

1、兼容swf的各种格式,主要是各种矢量命令和多种多样的图片格式;

2、实现高效的html5运行库,自主实现了位图缓存、自动脏区识别、脏区重绘等技术。

Fanvas的优势?

能转化swf为H5动画的工具,除了Fanvas还有大名鼎鼎的google和adobe的产品——swiffy和flashcc。 对比之下,Fanvas有如下优势:

1、从swf文件直接转化为Html5动画(google的swiffy和adobe的flashcc都不支持,两个产品都需要通过fla源文件处理);

2、精简编排的JSON数据,使swf转化后的js数据文件非常小,普遍比flashcc导出的要小20%到50%;

3、精简的运行库,混淆后只有35k,gzip后只有10k左右。而swiffy和flashcc的运行库混淆后都超过100K;

4、开源,可供使用者二次开发(请保留Fanvas字样或版权声明)。

如何使用?

只需要一键导入swf,转化完成后一键导出canvas动画js。

具体请参考bin目录的《使用说明》

源代码说明

exporter是as3.0实现的swf文件解析器,解析后输出json数据;

runtime是js运行库,用于解析json数据,转化为最终canvas动画。

DEMO

http://kenkozheng.github.io/fanvas/magicEmotion/demo1/

http://kenkozheng.github.io/fanvas/magicEmotion/demo2/

http://kenkozheng.github.io/fanvas/magicEmotion/demo3/

http://kenkozheng.github.io/fanvas/magicEmotion/demo4/

fanvas's People

Contributors

iazrael avatar kenkofox avatar kenkozheng avatar tencent-adm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fanvas's Issues

如何让导出的canvas动画透明?

有开发者提出,导出后的canvas动画默认使用了flash中的舞台颜色,如何实现透明,跟web其他元素叠加?

方法:
fanvas暂时没有加背景透明的配置,不过,大家可以在导出的swfData中,找到bgColor这个属性,删除或者设置为null,就能实现透明背景。
建议实际实现,可以在传入fanvas.play前,使用swfData.bgColor = null,这样的方式。

使用工具报错?

@kenkozheng

报错信息如下:

fanvas3-min.js:14 Uncaught TypeError: Failed to execute 'createPattern' on 'CanvasRenderingContext2D': The provided value is not of type '(HTMLImageElement or HTMLVideoElement or HTMLCanvasElement or ImageBitmap)'

按照项目中的Demo把script标签都放到了head标签中,同时写了定时器

查询错误之后发现可能是图片还没有加载结束就调用函数的原因,但是不知道该如何解决。求教

导出data.js如何导出

看了使用说明,打开flashplayer_14_sa_debug.exe,导入swf文件,之后导出data.js,但是flashplayer没有导出的按钮,这个要如何导出

请问我可以认为 frameActionList 的长度就是动画的实际帧数吗?

UPDATE:
刚发现有这个: totalFrames 。

我想在动画播放结束后做一些操作,但目前没有对应的参数。唯一的回调就是 onFrame . 如果 frameActionList 的长度就是实际的总帧数,我就可以:

onFrame: function() {
  if (frame >= frameActionList.length) {
    // ...
  }
}

谢谢。

报错:Uncaught DOMException: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The image argument is a canvas element with a width or height of 0.

我用fanvas转换某个swf后,得到如下错误:
Uncaught DOMException: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The image argument is a canvas element with a width or height of 0.
fanvas
错误定位到fanvas3-all.js的1263行代码的drawImage。使用如下方式可以规避问题:

cacheCanvas.width = cacheCanvas.width || 1;
cacheCanvas.height = cacheCanvas.height || 1;
ctx.drawImage(cacheCanvas, offX, offY, cacheCanvas.width/scale, cacheCanvas.height/scale);

能请问导致这个问题的原因是什么吗?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.