Code Monkey home page Code Monkey logo

two.js's Introduction

two.js

A two-dimensional drawing api meant for modern browsers. It is renderer agnostic enabling the same api to render in multiple contexts: webgl, canvas2d, and svg.

HomeExamplesDocumentationHelp

Usage

Download the minified library and include it in your html. Alternatively see how to build the library yourself.

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

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>

Custom Build

Two.js uses nodejs in order to build source files. You'll first want to install that. Next you'll want to install node-minify:

cd two.js/utils
npm install node-minify

Then open up ./utils/build.js in the text editor of your choice. You'll see an array at the top called files. This is the list and order of source files that get compiled to the built source. Feel free to add, subtract, or modify based on your needs.

If you're making an application and you're only using one renderer (i.e: svg context) then it is highly recommended to remove canvas and webgl renderers from your build in order to drastically decrease your file size.

Finally, build the project:

node two.js/utils/build

Change Log

Nightly

  • Added remove and clear methods to two instance
  • Fixed svg interpretation for webgl context
  • Added matrix property to all Two.Shape's for advanced transformations
  • Added inverse method to Two.Matrix
  • Remove execution path dependency on utils/build.js @masonbiler
  • Added timeDelta property to every two instance
  • Added gruntfile, package.json for more integration with npm, and dependency free build (build/two.clean.js) @iros
  • Crossbrowser compatability with noStroke and noFill commands

May 3, 2013 v0.2.0

  • First alpha release

Jan 29, 2013 v0.1.0-alpha

  • Proof of Concept built from Three.js

two.js's People

Contributors

jonobr1 avatar iros avatar masonblier avatar hlfcoding avatar

Watchers

 avatar

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.