Fanvas是一个把swf转为html5 canvas动画的系统

 
https://github.com/Tencent/Fanvas
 
使用方法:
Fanvas是一个把swf转为html5 canvas动画的系统_第1张图片
 
Fanvas是一个把swf转为html5 canvas动画的系统_第2张图片
 
代码:
DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    
    <title>Fanvas Demotitle>

    

    <script type="text/javascript" src="fanvas3-min.js">script>
    <script type="text/javascript" src="swfData.js">script>

    <script>

        function init() {

            setTimeout(function(){
                var canvas = document.getElementById("testCanvas");
//                alert(window.innerWidth + ' ' + window.innerHeight);
//                swfData.frameRate = 12;
                canvas.style.width = window.innerWidth + 'px';     //css控制最终实际显示的尺寸
                canvas.style.height = window.innerHeight + 'px';
                fanvas.play("testCanvas", swfData, {
                    cache: 2, autoPlay: true,
                    onFrame: function (index) {
                        //                    console.log("onFrame", index);
                        //                    if(index == 3){
                        //                        fanvas.pause("testCanvas");
                        //                        setTimeout(function(){
                        //                            fanvas.resume("testCanvas");
                        //                            fanvas.replay("testCanvas");
                        //                        }, 2000);
                        //                    }
                    },
                    //showFPS: 1,
                    scale: 1,
                    //clearAll: 1,
                    //showDirtyRect: 1,
                    imagePath: "./img/"
                });
            }, 100);

        }

    script>
head>

<body onload="init();">
<div style="position:absolute;left:0;top:0;" class="canvasHolder">
    <canvas id="testCanvas" width="1000" height="800" >canvas>
div>
body>
html>

效果:

Fanvas是一个把swf转为html5 canvas动画的系统_第3张图片
 
 

 

 
 
 
 

 

转载于:https://www.cnblogs.com/ChenChunChang/p/8268747.html

你可能感兴趣的:(Fanvas是一个把swf转为html5 canvas动画的系统)