zoukankan      html  css  js  c++  java
  • 使用百度zrender, demo抛砖引玉.

    http://www.just.org.cn/zrender/index.html

    https://github.com/ecomfe/zrender

    目录结构:

    |-project
        |-demo
            |-js
                |-main.js
            |-index.html
        |-libs
            |-requirejs
                |-require.js
            |-zrender
                |-src
                    |-zrender.js
                    ...

    src下面省略了很多, 其实就是将"https://github.com/ecomfe/zrender"中src下面所有文件夹和文件.

    自己写的就是 main.js 和 index.html

    main.js

    require.config({
    	packages: [
    		{
    			name: 'zrender',
    			location: '../../libs/zrender/src',
    			main: 'zrender'
    		}
    	]
    });
    require(
    	[
    		'zrender',
    		'zrender/animation/animation',
    		'zrender/shape/Circle'
    	],
    	function(zrender, Animation, CircleShape){
    		//
    		var zr = zrender.init( document.getElementById('Main') );
    		var circle = new CircleShape({
    			position: [100, 100],
    			scale: [1, 1],
    			style: {
    				x: 0,
    				y: 0,
    				r: 50,
    				brushType: 'fill',
    				color: 'rgba(33, 222, 10, 0.8)',
    				lineWidth: 5,
    				text: 'circle',
    				textPosition: 'inside'
    			},
    			draggable: true
    		});
    		zr.addShape(circle);
    		zr.render();
    	}
    );
    

    index.html

    <!DOCTYPE html>
    <html lang="en">
    <head>
    	<meta charset="UTF-8">
    	<title>zRender demo</title>
    	<script type="text/javascript" src="../libs/requirejs/require.js" data-main="./js/main.js"></script>
    </head>
    <body>
    	 <div id="Main" style="600px;height:400px;"></div>
    </body>
    </html>
    

    效果如下:

  • 相关阅读:
    ASP.NET Ajax基础-1
    项目管理必读之书-》人月神话
    Discuz2.5菜鸟解析-1
    Jquery初学者指南-1
    敏捷日记
    精品图书大推荐2
    Jquery初学者指南-2
    纯javaScript脚本来实现Ajax功能例子一
    周五面试笑话一则
    JavaScript基础-4
  • 原文地址:https://www.cnblogs.com/juedui0769/p/5084993.html
Copyright © 2011-2022 走看看