3 ms·
On this particular example from the article: https://www.khanacademy.org/math/basic-geo/basic-geo-coordinate-plane/basic-geo-shapes-on-a-plane/e/drawing-polygo
by datashovel 12y ago
On this particular example from the article:
https://www.khanacademy.org/math/basic-geo/basic-geo-coordinate-plane/basic-geo-shapes-on-a-plane/e/drawing-polygons https://www.khanacademy.org/math/basic-geo/basic-geo-coordin...
I would definitely not recommend using individual <svg> nodes. Instead what I did was wrote some basic wrapper functions to decompose and re-compose the internal attributes of <path>. If you get a chance to read the spec you'll see that you get the option of assigning RELATIVE or ABSOLUTE coordinates, which makes it very easy to do a simple editor like what you've done within a single <svg> node.
- spicyj 12y agoThat's what we had originally, but you lose out on the ability to take advantage of GPU hardware acceleration (in current browsers, at least; there's no actual technical reason preventing GPU acceleration for SVG drawing that I know of).
- datashovel 12y agoI am probably assuming several things about how that would be implemented. I personally decided to abandon the idea of using Raphaeljs because it appeared to assume too many things about how I was going to be interacting with the SVG objects on the canvas. I found that (for my purposes) working directly with the objects was a huge win in terms of performance.
- datashovel 12y agoHaven't looked enough at it, but I've been meaning to dig in to http://snapsvg.io/ http://snapsvg.io/ to see if it is any better. Apparently done by the same guy behind Raphaeljs