Hacker News new | ask | show | jobs
by rjusher 3986 days ago
What I am struggling with, is the use case of a library like this.

Is this oriented towards gaming or substitude something like d3.js or is it has a simplier api, for the developer than other libraries. Or is it a library to showcase the cool stuff that can be done with new technologies.

I think the main difference and the selling point is that it is "renderer agnostic" but I don't understand the benefits of that.

5 comments

Renderer-agnostic is nice, actually, when you need to support lots of different browsers.

Some mobile browsers can't do WebGL as fast as they do Canvas, for instance. Other browsers will have a huge speed advantage with WebGL.

I'm not sure if any are faster with SVG, or the relative performance between SVG and canvas. But being able to do some test renders quickly in all three modes should allow you to select the fastest for a particular browser.

Game developers are better off with a game-oriented library, IMO. Even if you used something like Two.JS to do your rendering, there are a lot of things still useful in a game library to justify using it -- and most games will need more than geometric figures.

I love SVG support because it means you can render something in vector art in the browser which is also downloadable as a file by the user. Drawing stuff in the browser which is then stuck there is cute but lacks an important layer of interoperability with the rest of the computing ecosystem. So here we appear to get the best of all worlds: render to whatever is fastest in the browser but get automatic "export as SVG" for free.
We could make an HTML-Canvas-compliant library that renders SVG.

In fact, I already enabled one: https://github.com/Automattic/node-canvas

You can save out a <canvas> to png quite easily: canvas.toDataURL();
Oh, yes, but it's not a vector format, which means you can't make high quality vector drawings that the user can export with it.
Even Dojo Toolkit's dojox.gfx from 2007 supported multiple rendering contexts: SVG, canvas, VML, Silverlight. https://dojotoolkit.org/documentation/tutorials/1.10/gfx/
I don't know what the real use case is, but I know that it's been awesome as a simple graphics API to teach programming to kids.

A while back I used Choc (http://www.fullstack.io/choc/) to teach JavaScript to a high school class. A lot of Two's competitors have APIs that take into account things like performance and extensibility, but are harder to explain because of it. It was great to have a simple API that got out of the way and allowed me to teach things like if statements, for loops and functions.

The author of two.js uses it for interactive art, like Patatap. It's great for creating fun motion design easily. I worked with him on a project where a live drummer plays drums and triggers sounds and shapes projected behind him: http://thecreatorsproject.vice.com/blog/introducing-drumpant...
It's for motion graphics, with no facilitation for motion graphics! Brilliant!
It would be good if you wanted to make some content that has smooth animations that renders in all different browsers (i.e animated greeting cards, animated presentations, or animated websites). Basically anything that you could do in Flash 2D, you could also do with this.

Example: makemake.io (although PIXI.js is used in this case)