二維繪圖API:two.js

jopen 9年前發布 | 21K 次閱讀 two.js JavaScript開發

一個適用于現代瀏覽器的二維Web繪圖API。它是渲染器無關的,支持在多種上下文環境(webgl, canvas2d,和 svg)中使用同樣的API。

Home ? Examples ? Documentation ? Help

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.baiduhome.net/lib/view/home/1437372689131

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!