Svg.js
svgjs.com
svgjs.com
While tools to dynamically generate SVG are needed sometimes the big future of SVG is artist-created images, so we generally in need of ways to manipulate , animate and add-to existing existing SVG images. SVG markup is already a better: clearer, faster, more embeddable way to create SVG images. Our tools should focus on adding value to the markup.
I use a lot of SVG these days and, sadly, SVG has to come with caveats. It currently performs terribly on iOS devices (especially large, detailed images) and there is no way to create progressively detailed svgs or mark areas for baking. Webkit did have an SVG scrolling bug where svgs were constantly repainted but, thankfully, that is fixed now.
Another gripe is SVG drawing tools. I am using a rather strange hodge-podge of a workflow (especially as I am a Mac user). Microsoft Expression Design → export as XAML → translate XAML to SVG.
It's actually quite effective / sensible for a few reasons 1) Expression Design is now a free download 2) XAML and SVG are very similar so the translation is reasonable straight-forward 3) Expression Design gives accurate pixel previews (and I have a second SVG testing tool that can flick between SVG and PNG to see where there are problems).
My tools are written in Go and may be of use / interest to other people. Let me know if you'd like to try them (caveat: they are one-user-one-developer-tools — me — so there is a layer of polish missing that I am happy to live with but you may not) and I'll work out how to upload them to GitHub.
I haven't myself, but have you tried two.js for SVG manipulation? It seems geared towards that.
Expression Design has a very simple, powerful interface: scroll is zoom, space bar is pan, unmodified click is select. I'd like to see someone make an SVG editor with a cross between it and Bret Victor's Gestural Zoom And Pan.
I've created a small JavaScript library for SVG, called "Pablo": http://pablojs.com
It packs in a lot for its size. Pablo lets you create and manipulate SVG, somewhat similarly to using jQuery and Underscore.
For those near Brighton, UK - there's a launch event this Friday: http://brightondigitalfestival.co.uk/events/pablo/
and it's nice to see it green across the board. Even the mobile browsers.
https://github.com/ityonemo/dali.js
part of what i did was to add into the prototype of SVG objects attributes that were getter/setter that you would expect, so the SVGCircle object, now has a cx, cy, rx, ry members. The advantage to this is that JQuery's animate() function has a secret ability to animate object members (I remember understanding why that was there at some point, but now I forget), so you could just use the $.animate() to get all of your animation done, even though those values are in the attrs list and not in the styles attr.
MIT and BSD are "public domain"ish licenses, which have stood up to decades of scrutiny and usage by lots of projects. They'd be good choices. But, there are many others that also meet that description.
I also understand the liability part of the licence and I think it's disgusting: Limiting your liability by indemnifying yourself with a statement that no one is going to read, as far as I'm concerned, also means that you've lost. If someone wants to sue me for misusing my software then they can live out the rest of their lives as the miserable, tortured soul that they obviously are.
those countries that don't have public domain concepts are obviously putting themselves at an economic disadvantage - so they'll get what's coming to them. I only fear that we are headed that way in this country.
then don't use my code. In the end, what you do is your choice, but I'd rather not get the state involved in my acts of sharing - and that should implicitly suggest that I'm not interested in leveraging the state to take from you. If you can't trust that, then fine. I'm sorry for you.
Now I am not suggesting that you strap boilerplate to it, however a note that reassures people of their freedom to use the code without fear of reprisal is a polite consideration.
It is not because of wishing to be protected by the law, but rather trying to avoid being bashed over the head with it at some unspecified future time.
To expect complete strangers to trust that they understand your motives and opinions on the matter of whether they can use your work without worrying about it, would seem to be a stretch, at least in the general case unless it is made reasonably explicit, because a lot of the time society does not act that way and so it is useful to have some form of social signalling to let people know what the score is, which is all that licences are anyway, when you get right down to it.
And as far as trust goes, this is not a binary proposition, the middle ground is vast and has jungles in it.
I might do that. My other software comes with copyheart notices, I just hadn't gotten around to tacking it onto dali yet.... Originally dali is part of a now-on-ice project, which carried the notice.
Excellent work!
Like this:
<object data="http://www.3quarks.com/images/svg/station-clock.svg" type="image/svg+xml" width="200" height="200"> <param name="dial" value="din 41091.1"/> <param name="hourHand" value="swiss"/> <param name="minuteHand" value="swiss"/> <param name="secondHand" value="swiss"/> <param name="minuteHandBehavior" value="stepping"/> <param name="secondHandBehavior" value="sweeping"/> <param name="secondHandStopToGo" value="yes"/> <param name="secondHandStopTime" value="1.5"/> <param name="backgroundColor" value="rgba(0,0,0,0)"/> <param name="dialColor" value="rgb(40,40,40)"/> <param name="hourHandColor" value="rgb(20,20,20)"/> <param name="minuteHandColor" value="rgb(20,20,20)"/> <param name="secondHandColor" value="rgb(160,50,40)"/> <param name="axisCoverColor" value="rgb(20,20,20)"/> <param name="axisCoverRadius" value="0"/> <param name="updateInterval" value="50"/> </object>
[0]http://www.dezeen.com/2013/08/07/stop2go-by-mondaine-at-deze...
it's not like canvas is slow (EaselJS' cache is a savior in this case). it's more like it hurts for me to even think of all the complex operations a canvas lib has to do to cope with various mouse interactions (calculating the objects under the mouse pointer), animation redrawing etc.
we'll see how svgjs copes with that.
Have you actually had problems with EaselJS?
but problems? yes. for example, the default EaselJS build strips out such DisplayObject methods that are not documented but are present in the unbuilt source code, e.g. getBounds(). I do understand there are reasons for it being undocumented, sure -- calculating bounds for a raster object may be very expensive on canvas, but since I'm working with strict square shapes, it works for me very well, hence I've got a custom EaselJS build to maintain.
I also had some problems with TweenJS (a tween co-lib for EaselJS) -- this was also solved by a custom build, as the downloaded minified version they're currently hosting was not up-to-date with EaselJS' newest changes (at least it wasn't couple of days ago).
that said, even though my code is not quite render-agnostic, I'll definitely try out Svgjs, as it's methods are almost one-on-one match to EaselJS'.
I don't know how easelJS works, but the other really nice thing about svg is that modification of some attributes (color, stroke-width, etc.) is done using CSS, so if you, say, wanted to have the user be able to customize the interface in general cases (I was using this to annotate DNA which usually are done with arrows - one user might want genes in yellow and promoters in green, another vice versa, etc) that's a trivial implementation; no need to write a custom lookup table.
I have done myself something similar [1] for PHP's Zend\Pdf library, calculating string lengths and breaking lines.
Also, it is worth mentioning Dojo's GFX library.
Here's a video: http://www.youtube.com/watch?v=mPw0WNrBWuY
Raphael also seems to be a bit more about abstracting SVG away from you, where SVG.js is more direct manipulation of the SVG document.
I wanted a library that still breathed SVG while providing a more unified API. I think too much abstraction leads to isolation. It's important to stay in touch with the underlying language, SVG.
-bowerbird
i'm sure this _looks_ like a non-informative post, at least to some of you, so let me explain exactly why i made it...
mine was the first comment on this post, which languished for an hour with nothing, and looked to be on its way to being ignored totally, like the vast majority of posts...
i made a comment so people would come and look and maybe, just maybe, add a more meaty one of their own. it worked.
i wanted the entry to get some attention, because i believe s.v.g. is a highly underutilized format, and that has been true for about a decade now, more or less, so even though i don't have a lot to say about the topic, because i know so little about it, i wanted to say "right on, thank you!".
which is exactly what "yay" meant...
could i have dressed it up with a little fat on the bones, so it was more than just "yay"? yes, i could have. easily.
but at heart, it still woulda been nothing more than "yay".
so i decided to go with _the_plain_truth_of_the_matter_.
and if you want to down-vote that, then go ahead and do it.
i don't really give a dxmn. i don't have that much "karma", and i don't intend to spend much time trying to procure it, so your little brownie-points don't mean jxck-shxt to me...
(they certainly don't deserve any unadulterated profanity!)
this post got some attention, and i did my part to help it, so i'm quite happy with what i did. and i'll do it again.
-bowerbird
- Hidden Taco