Description
Two.js is a two-dimensional drawing API for modern web browsers. Its main idea is that the same code can draw in several renderers, including SVG, canvas and WebGL, so you write a scene once and choose where it is drawn. It is aimed at flat vector shapes and their animation, and it keeps a scene graph, which means that each shape or group is stored as an object that you can rotate, position and scale after creating it. The library has a built-in animation loop that can run on its own or be paired with another animation library. It can also load SVG files, including those exported from design tools such as Adobe Illustrator, and bring them into a scene. For bitmap images, it can load single images, sprite sheets and image sequences with a few method calls. The development build is about 95 KB and the production build about 50 KB. You install it with npm install --save two.js@latest, or add the script to an HTML page. The site says that before version 0.7.0-alpha.1 it needed Underscore.js and the Backbone Events module. The documentation covers drawing a first shape, groups, motion, and next steps, and the examples show more.…
Highlights
- Same code for SVG, canvas and WebGL
- Scene graph of shapes and groups
- Built-in animation loop
- SVG import from design tools
- Sprite sheets and image sequences
Ratings & Reviews
No ratings yet
Be the first to rate Two.js.
People also visit
Two.js FAQ
What is Two.js?
A two-dimensional drawing API for the browser that draws shapes and animations in SVG, canvas or WebGL.
How do I install it?
Run npm install --save two.js@latest, or download the script and add it to your HTML page.
How big is it?
The site lists about 95 KB for the development build and about 50 KB for production.
Can I use SVG from Illustrator?
Yes. The site says you can create SVG elements in design tools such as Adobe Illustrator and bring them into a Two.js scene.
Does it have animation?
Yes. It has a built-in animation loop, which can also be paired with another animation library.
Does it need other libraries?
Before version 0.7.0-alpha.1 it needed Underscore.js and the Backbone Events module. Newer versions do not, according to the page's notes.
What are the best Two.js alternatives?
Popular alternatives to Two.js include Paper.js, Ripl and Motion Canvas. See all Two.js alternatives



