二维绘图API:two.js

jopen 9年前

一个适用于现代浏览器的二维Web绘图API。它是渲染器无关的,支持在多种上下文环境(webgl, canvas2d,和 svg)中使用同样的API。

HomeExamplesDocumentationHelp

Usage

Download the minified library and include it in your html.

<script src="js/two.min.js"></script>

It can also be installed vianpm

npm install --save two.js

Alternatively see how to build the library yourself.

Here is boilerplate html in order to draw a spinning rectangle in two.js:

<!doctype html>  <html>    <head>      <script src="js/two.min.js"></script>    </head>    <body>      <script>        var two = new Two({          fullscreen: true,          autostart: true        }).appendTo(document.body);        var rect = two.makeRectangle(two.width / 2, two.height / 2, 50 ,50);        two.bind('update', function() {          rect.rotation += 0.001;        });      </script>    </body>  </html>

项目主页:http://www.open-open.com/lib/view/home/1437372689131