{"id":2148,"date":"2010-10-29T11:56:57","date_gmt":"2010-10-29T10:56:57","guid":{"rendered":"http:\/\/toki-woki.net\/blog\/?p=2148"},"modified":"2022-03-29T21:53:02","modified_gmt":"2022-03-29T20:53:02","slug":"svg-to-raphaeljs","status":"publish","type":"post","link":"http:\/\/toki-woki.net\/blog\/p2148-svg-to-raphaeljs","title":{"rendered":"SVG to RaphaelJS"},"content":{"rendered":"<p>While redesigning this blog I wanted to keep the &#8220;<a href=\"http:\/\/www.flickr.com\/photos\/quentin-t\/5077332811\/\">one color per post<\/a>&#8221; concept I had in the previous version by changing (tweening) the logo&#8217;s color accordingly to the article being viewed (or scrolled to). I rapidly realized I couldn&#8217;t achieve this with just HTML+CS+JS and I didn&#8217;t want to use Flash (mainly because of iOS devices but also to avoid loading a SWF file on every page).<\/p>\n<p>I remembered hearing \u2014\u00a0<a href=\"http:\/\/twitter.com\/#!\/tokiwoki\/status\/15779949398\">a few months earlier<\/a> \u2014\u00a0about <a href=\"http:\/\/raphaeljs.com\/\">Rapha\u00ebl<\/a> (a JS lib to render vector graphics). At that time I found the concept really interesting but couldn&#8217;t see where to use it.<\/p>\n<p>OK, so I know what I want to do, I know the tools I&#8217;ll use, but how do we do that? Rapha\u00ebl is cool, but its syntax looks <a href=\"http:\/\/raphaeljs.com\/icons\/\">a bit cryptic<\/a> at first. It says it handles SVG, and \u2014 guess what \u2014 Illustrator can export to SVG. We&#8217;re getting closer&#8230;<\/p>\n<p>SVG is XML, but Rapha\u00ebl doesn&#8217;t eat XML, it eats a specific syntax meant to be compatible with SVG and VML. Hum&#8230; This is when I fire Flash Builder and start writing code. The goal: accept an SVG XML file as input and spit some &#8220;Rapha\u00ebl-compatible script&#8221; out.<\/p>\n<p><a href=\"http:\/\/toki-woki.net\/p\/SVG2RaphaelJS\/\">Boom<\/a> (plus a <a href=\"http:\/\/toki-woki.net\/p\/SVG2RaphaelJS\/demo\/\">little demo<\/a> of an output).<\/p>\n<p>I then simply had to export my Ai logo to SVG, open it in SVG2RaphaelJS, copy paste the output, and wire all that to the scroll\/color tweening logic. Pretty easy.<\/p>\n<p>Everything worked and looked nice on all browsers and OS&#8217;s but I realized the sole idea of having a logo changing colors didn&#8217;t work that well. For purely visual reasons. So I dropped it from my theme and rolled back to the black PNG version you can see right now.<\/p>\n<p>The good thing is, <a href=\"http:\/\/toki-woki.net\/p\/SVG2RaphaelJS\/\">the tool<\/a> works pretty well (at least with Illustrator SVGs) and is <a href=\"http:\/\/code.google.com\/p\/as3-bits\/source\/browse\/trunk\/apps\/SVG2RaphaelJS\/src\/SVG2RaphaelJS.mxml\">OpenSource<\/a>. Either use it or modify it, and tell me what you think. I did this in a hasty fashion and I probably won&#8217;t use it a lot, so don&#8217;t expect updates or bug fixes&#8230; But if you feel like improving it, please do so!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>While redesigning this blog I wanted to keep the &#8220;one color per post&#8221; concept I had in the previous version by changing (tweening) the logo&#8217;s color accordingly to the article being viewed (or scrolled to). I rapidly realized I couldn&#8217;t achieve this with just HTML+CS+JS and I didn&#8217;t want to use Flash (mainly because of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,6],"tags":[42,41,19,89,30,55],"acf":[],"_links":{"self":[{"href":"http:\/\/toki-woki.net\/blog\/wp-json\/wp\/v2\/posts\/2148"}],"collection":[{"href":"http:\/\/toki-woki.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/toki-woki.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/toki-woki.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/toki-woki.net\/blog\/wp-json\/wp\/v2\/comments?post=2148"}],"version-history":[{"count":11,"href":"http:\/\/toki-woki.net\/blog\/wp-json\/wp\/v2\/posts\/2148\/revisions"}],"predecessor-version":[{"id":2241,"href":"http:\/\/toki-woki.net\/blog\/wp-json\/wp\/v2\/posts\/2148\/revisions\/2241"}],"wp:attachment":[{"href":"http:\/\/toki-woki.net\/blog\/wp-json\/wp\/v2\/media?parent=2148"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/toki-woki.net\/blog\/wp-json\/wp\/v2\/categories?post=2148"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/toki-woki.net\/blog\/wp-json\/wp\/v2\/tags?post=2148"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}