SitePoint: Right, I thought my first question should be: why did you write Raphaël? What inspired you to write it?
I was doing a FedEx project. Internally at Atlassian, we have FedEx Days when you are given the time to present a project you’ve been working on.
SP: FedEx Day–did you say?
It’s called "FedEx" because you have to deliver something cool. You show it off at a small competition (it’s not about big prizes–it’s more for fun), and of course it should be related to the projects you work on. Because I’m a front end engineer and all the other guys are Java developers, I thought I’d focus on a front end project that will impress people. It’s hard to impress back end developers.
So I thought I’d do something the programmers might not know anything about, and because I’ve had experience with SVG before, it made sense to work with SVG. But, as a front end developer, I’m concerned about creating something that only works in Firefox, so I wanted to create a bridge for VML on IE. My original project was to create a charting application, like a simple line chart. I quickly knocked it up in a day and a half from scratch, showed it, but it didn’t win anything. It didn’t impress people.
SP: Not even a little bit?
Oh, maybe a little bit, but not in general. So I left it for a while. Then we started our 20% projects (just like Google). I decided to pick up this project and extend it a little bit. I got rid of the charting part and turned it into a generic drawing library. Just a bridge between SVG and VML to enable me to do more cool stuff without worrying about browser compatibility.
So at the next FedEx Day, I used this library to create a Skitch-like application. You could take a picture and add things like arrows and ellipses. It even saved the image, but obviously that’s not the hardest part.
Then I started working more on this 20% project. To be honest, I spent more than one day a week: I worked with my laptop on the train — one hour to work and one hour back — two days a week in general, for about a month. Then I decided that it was good enough to release, because it’s better to do so before another developer releases the same thing. So, I released it in the middle of August.
I was stunned by the feedback. I didn’t expect it, to be honest, because I wrote about it on my blog and I usually get about 20 hits per day; but after it was released and made it to the front page of Delicious and Reddit, I got about 8,000 hits per day. It chewed through my bandwidth and I had to create a new domain. It actually started costing me money!
SP: So do you actually use it in your job at Atlassian?
Not yet, but we have plans to integrate it into products for charting and so on, but we haven’t found many use cases for it so far. I Personally think people are a bit afraid of the technology. But I hope it will find a place. It’s still quite raw. So it’s enough to show the concept, have fun, and do some stuff here and there. I’m always finding bugs (especially bugs for IE), so it’s not really, absolutely ready. Well, it’s only one month old.
SP: Where would you like to see it used?
Oh, well, everywhere. World domination is my goal! Of course the first thing people think of is charting, and that’s how I came to this idea, but what I was trying to show was that charting is just one obvious part. You could use it to add effects to a page, like the rotation of an image.
Say, if you’re on Flickr and you want to rotate an image by 90 degrees because you’ve shot the photo on the side. Currently, you press a button, it sends the request to the server, the server does the rotation, sends it back, and you see the rotated picture. Instead, you could use Ajax to just send the basic information: rotate 90% to the right, and on the client you’d have a smooth animation of rotating to the right. That would be a much more pleasant experience to the user for obvious reasons.
It’d be cool, and it’s really easy to implement using Raphaël. Without it, it’s a bit complicated to implement because you have to do a the IE version separately from the version for all other browsers. Actually that’s the whole reason why I built Raphaël — you do something in FireFox and in IE it just works. It’s not absolutely there yet, but it’s getting there.
SP: When I was doing my demo I did notice one snag. In all the non-IE browsers you could do a path, then avoid specifing a fill color, and it would just draw the line. But in IE if you didn’t specify a fill color it would choose white, and it would start attempting to fill in the white.
Yeah, I fixed it.
Learn PHP for free!
Make the leap into server-side programming with a comprehensive cover of PHP & MySQL.
RRP $11.95 Yours absolutely free
SP: Oh really? Oh good, fantastic. Because I resorted to setting the fill opacity to 0.
Yeah I noticed it when I looked at the code I thought “Oh, why did you use opacity for the fill?” So I started playing around and thought “Ah yeah, oh, ok.”
SP: Hey thanks!
Yeah, I often find bugs when I test in IE. SVG and VML are absolutely different languages. You can’t really replace one with the other. Sometimes it’s just impossible to do something in IE that’s easy to do in SVG. So I have to find a compromise solution. I can’t have an API for something you can’t do.
For example, in SVG you can rotate an object around a point, while in IE rotation is very wonky; you can’t specify the point. It rotates around some magical center and this center point is very randomly located in the center of… well I don’t know what it’s the center of. I found if you put the object inside a group it will be the center of the group, and it would do some juggling of the objects and they’d be jumping around the place. So I’ve succeeded in getting all the objects to rotate around their centers in all the implementations, but people ask me if they can specify the point of rotation. I say “Oh yeah, I wish.” So, not yet, but maybe later. I wish to do it, but it’s not that easy to do. In SVG it’s easy; it’s built in. But in VML it’s not.
SP: I thought it was maybe a weakness but also a strength of Raphaël, that if you approach the task thinking about how you can doing it using the Raphaël API then you avoid those kinds of problems.
Well maybe, sort of… Well for example I was trying to implement a blur effect and you can do it in Explorer, Firefox, and Opera, but Safari doesn’t support it, surprisingly. As soon as I discover I can’t do something across all browsers I don’t add it to the API. As soon as Safari supports it I’ll put it in. But for now there’s no point because the whole point of Raphaël is that you write it and it just works. Well, I hope it will. In version 1 it should be like that.
It could also help you to understand, you know, if you try to do something and you say “Could I do this cross-browser?” The answer may well be “No.” Of course, when I was creating Raphaël I was trying to cover as much functionality as possible, so if I removed something I removed it for reason. Maybe I’ll find a way to do it later, maybe there’s no way to do it in Internet Explorer.
I wouldn’t say easily. There are some things that Flash is good at, like streaming video and animations. But if you look at, for example, the Google Analytics charts, then I can’t see any reason why it can’t be done with Raphaël.
I don’t think it will replace Flash, but if in some task you could use SVG instead of Flash, I’d be happy to see that. Something native, something you can hack–the whole concept of the open web. SVG, and even VML, is more open than Flash. You can hack it up, you can view source, whatever. And, of course, Flash doesn’t work on iPhone. That’s another reason for doing this using native browser technologies. I’m not talking about Raphaël specifically; I think SVG is the way to go for a lot of things.
When you talk about images and charts–and whatever SVG produces, it’s always an image, dynamic or not–it’s always an accessibility issue. At my talk, we spoke about how a screen reader should read SVG; how they should read circles, and ellipses, and combinations of them. Even if you had a good parser that could read the shapes you create on the page, you couldn’t tell what the shapes actually create: the final image. It’s really complicated and very difficult to explain if the user is blind. Like how would you explain the Web Directions logo to a blind user? I don’t think screen readers will ever be able to do this.
I don’t think it’s a problem with SVG, or a problem with Raphaël; I think it’s a generic problem and there are already many articles and books about how to deal with it.
SP: Well thank you very much, really good to talk to you
iOS Developer, sometimes web developer and Technical Editor.
Jump Start Git, 2nd Edition
Visual Studio Code: End-to-End Editing and Debugging Tools for Web Developers