News for hackers. Stuff that matters.
Re:Paper.js — The Swiss Army Knife of Vector Graphics Scripting by haberman on Monday June 27, 2011 @01:49PM (#2702214)
Why implement vector graphics on Canvas when you could use SVG?

EDIT: Seems to be answered in the FAQ: "We have decided to use the Canvas object as the main backend for now because it is faster than SVG and allows us to implement and optimize our own Scene Graph / Document Object Model. We will be offering SVG (and hopefully PDF) importing and exporting in the future."

But it seems hard to believe that doing vector->bitmap rasterization in JavaScript is going to be faster than using the browser's SVG implementation (written in C++).

Re:Paper.js — The Swiss Army Knife of Vector Graphics Scripting by epistasis on Monday June 27, 2011 @02:26PM (#2702405)
There's no reason that a Canvas implementation would be doing rasterization in JavaScript; the Canvas API is like Postscript or the Cairo API, and javascript will only be calling high-level functions such as specifying gradient or Bezier curve parameters.
Re:Paper.js — The Swiss Army Knife of Vector Graphics Scripting by csytan on Monday June 27, 2011 @01:52PM (#2702227)
I don't think SVG is particularly suited to animation, as it would require manipulating multiple DOM elements. This tends to be quite slow compared to redrawing the canvas.
Re:Paper.js — The Swiss Army Knife of Vector Graphics Scripting by MatthewPhillips on Monday June 27, 2011 @02:17PM (#2702363)
SVG is hardware accelerated in IE9 and coming to Chrome as well. When that happens I doubt there will be much of a difference performance wise. Canvas and SVG will serve different ends. Doing something like GUI in Canvas would be an incredible pain, whereas doing it in SVG (using raphael.js) is a breeze. Canvas is better for games.
Re:Paper.js — The Swiss Army Knife of Vector Graphics Scripting by haberman on Monday June 27, 2011 @02:09PM (#2702327)
The alternative is keeping your own "DOM" of vector objects in a JavaScript-based scene graph. Why would this be more efficient than manipulating the DOM?
Re:Paper.js — The Swiss Army Knife of Vector Graphics Scripting by donpark on Monday June 27, 2011 @04:49PM (#2702958)
Because DOM elements are much heavier than Javascript objects in size, query/update performance, and update requirements.
Re:Paper.js — The Swiss Army Knife of Vector Graphics Scripting by euroclydon on Monday June 27, 2011 @02:24PM (#2702396)
Don't forget SMIL.
Re:Paper.js — The Swiss Army Knife of Vector Graphics Scripting by perfunctory on Monday June 27, 2011 @04:41PM (#2702927)
This is what amuses me about software. SVG which is specifically designed for vector graphics is slower than "not native" solution.
Re:Paper.js — The Swiss Army Knife of Vector Graphics Scripting by epistasis on Monday June 27, 2011 @04:58PM (#2702976)
The problem with SVG was that it wasn't really designed as much as it was dreamed. And it was also dreamed up in the middle of the whole "all data must be shoe-horned into XML" collective nightmare, which makes it less than ideal as a scene graph.

It was also abandoned as soon as Adobe acquired Macromedia, and thus Flash, meaning that there was no longer any reason for Adobe to push for a Flash alternative. There have never really been any good implementations, and it seems as though the spec wasn't written by anybody who'd have to eventually write an implementation.

Re:Paper.js — The Swiss Army Knife of Vector Graphics Scripting by haberman on Monday June 27, 2011 @05:05PM (#2703011)
Any specific criticisms of SVG's design (or references to such), besides being built on top of XML (which is unfortunate, I agree)?

Also, what's wrong with the mainstream SVG implementations, like in WebKit and Gecko?

Re:Paper.js — The Swiss Army Knife of Vector Graphics Scripting by epistasis on Monday June 27, 2011 @06:43PM (#2703277)
For many many years the web browser implementations have been buggy and incomplete, and it was always difficult for me to figure out what I could and couldn't use on which browsers and which operating systems. I don't have any specific complaints other than a myriad of tiny tiny headaches that I've left in the past. A lot of them revolved around text APIs and especially the DOM interfaces. I ran into far fewer bugs and inconsistencies when just using static XML.

From what I can tell the browser implementations are getting much better. It has been very odd that browsers have been shipping half-broken implementations for years, and the specification was released in 2003, a full eight years ago.

I think that the failure to implement SVG can largely be traced back to the extreme breadth and complexity of the specification. It's much easier to read through the specification for OpenGL or Postscript than it was to make it through the SVG specification, though I admit that a procedural API is almost necessarily simpler and easier than a stateful scene graph that includes a procedural API on top of it. Maybe SVG Tiny and Mobile mitigate the problem, but those came far too late to make a difference, and SVG 1.1 certainly wasn't deprecated in favor of a smaller and more implementable set of functionality.

In ay case, I'm not going to be guinea pig for SVG again. I may pick it up when others have proven that it has several interoperable implementation on separate OSs, but I still consider it one of the bigger time-sucks and poor architectural decisions I've made. /rant

Re:Paper.js — The Swiss Army Knife of Vector Graphics Scripting by haberman on Monday June 27, 2011 @07:39PM (#2703425)
Thanks for writing that up. I've gotten more interested in SVG ever since Protovis's successor d3 adopted an approach of writing SVG directly. d3's has some impressive demos built on top of SVG in an impressively small amount of code: http://mbostock.github.com/d3/

I do think it's unfortunate that lots of W3C standards like SVG were well-positioned to be very widely used, but ended up being so big, complicated, and not informed by actual implementations. I've ranted about this before: http://news.ycombinator.com/item?id=2521885

Re:Paper.js — The Swiss Army Knife of Vector Graphics Scripting by david927 on Tuesday June 28, 2011 @03:52AM (#2704497)
You say it much more eloquently than I could but I wholeheartedly agree. I'm done getting bitten by SVG when Canvas, while more work, never bites.