Log in

No account? Create an account
Vector graphics in the browser - Arvind Narayanan's journal [entries|archive|friends|userinfo]

Vector graphics in the browser [Dec. 11th, 2007|12:28 pm]
Arvind Narayanan
[Tags|, ]

Update: Look at all the nifty stuff people have done with the canvas tag and mapping it to IE: graphs, a whole UI and a nifty reflections script. It's a pity this doesn't seem to be more widely known. Bottom line: <canvas> is here, it's fast, easy and widely available. Use it, people!

At least until a new de-facto standard comes along. I wouldn't mind Silverlight.. I know I'd sell my soul to be able to write in python for the browser.

P.S. I accidentally deleted this post and had to repost it. Sorry if it showed up again.

Following up on my previous post on hacking CSS to draw stuff, haran points me to arbitrary triangles in javascript. Now that, IMO, is an example of the perfect hack -- completely useless yet fiendishly clever. I thought about creating triangles but I didn't realize that borders could be exploited.

My own hack, while not nearly as clever (hey, I only spent a couple of hours on it), is a nice complement because it lets you draw arcs of circles in (nearly) arbitrary configuration. The hack value in both cases comes from exploiting side-effects of rendering for completely unintended purposes.

Of course, underlying this whole discussion is the assumption that while you can draw anything at all using 1-pixel divs, that should offend your sensibilities as a programmer and you should never, ever stoop to such depths if you want to keep your self-respect.

Nevertheless, I say these hacks are useless because the canvas tag is supported by all browsers but one (no points for guessing which one), and there exist at least two mapping tools to turn canvas markup into IE's VML.

This raises the obvious question though: if client side vector graphics is widely available, why aren't we seeing more of it? Why, for instance, doesn't google presentations let you draw circles, ellipses and the whole shebang? And if you have a site with lots of graphs, why not simply send the data over to the client and let it handle the rendering, saving a ton of bandwidth? Any guesses?


[User Picture]From: ephermata
2007-12-12 08:58 am (UTC)
wait, can't you write in Python for the browser with silverlight now? There's ironPython for the .NET VM, and silverlight lets you access the DOM. There's a note here that says silverlight v.1.1alpha has ironpython support:

also check our DLRpad:
"Using DLR Pad you can define a sample UI using XAML and then script against it using IronPython or IronRuby."

There's also Volta, if you feel like compiling into javascript...
(Reply) (Thread)
[User Picture]From: arvindn
2007-12-12 09:17 am (UTC)
oh, those are great for in-house deployments and such, but i'm not sure if silverlight is suitable for general use yet.

it isn't available for linux, and in any case there's an install process so most people who don't have it installed yet will just go away rather than jump through hoops.

i glanced at volta the other day. sounds like trademark microsoft overengineering :) (admittedly knee-jerk opinion) i dunno, it might be suitable for large complex projects.. i didn't find it very appealing.

so i see you're getting into the facebook game.. hows that going? anything else you're working on?
(Reply) (Parent) (Thread)
[User Picture]From: ephermata
2007-12-12 09:26 am (UTC)
There is Moonlight for Linux, but yeah, if you're developing on linux or want to reach people with it silverlight is not the best shot. I think the needs to be installed will become less of an issue over time. Especially since major league baseball is planning to use it for their site. ; )

Facebook is a fun distraction for me, but the platform is kind of unstable. Right now every single app on facebook appears to be down. Features come (or go) every week. It is cool to have people using the RandomSong app from all over, though, and the speed with which I can add new features is nice.

Other than that I'm mainly working on my thesis stuff -

which is coming along but I'm trying to bugfix right now.
(Reply) (Parent) (Thread)
[User Picture]From: arvindn
2007-12-12 09:42 am (UTC)
right, and netflix and a bunch of others too. i hope for once the superior technology wins. there's too much money and weight behind flash, so it's not going away no matter how crappy it is, but when i'm wearing my developer hat i'll be happy as long as silverlight can get a reasonably widespread installed base.

re. facebook, i really like chris anderson's advice "social networking should be a feature, not a destination". if you're doing it just for fun you probably don't care, but still..

good luck re. thesis!
(Reply) (Parent) (Thread)
[User Picture]From: ephermata
2007-12-12 10:01 am (UTC)
Flash won't go away. That's clear. What Silverlight does, though, is make it easier to come up with a quick prototype that can transition to production without too much pain. Then once you've proved the service works, you can do the flash version. After Silverlight gets enough installs anyway.
of course, I don't do any programming in either one. yet.

Anderson's article is interesting, but it seems to apply most to sites that already have a key functionality or brand of their own. RandomSong doesn't have that, and I'm not sure it'd make sense to do it as a standalone. The last.fm site and even the Zune Social look more like what he's talking about, though, where the social networking is a feature of the whole music experience and music discovery. incidentally, I've been really loving the zune pass for the last few weeks, mainly because it makes it painless to try out new music and follow up on friends' recommendations.

thanks for the good wishes. am debugging stuff right now...
(Reply) (Parent) (Thread)
[User Picture]From: arvindn
2007-12-12 10:11 am (UTC)
why should you transition to flash once you want to go to production?? anyway i'm not really very familiar with either technology either so i'll let it pass.

i understand that about anderson's article. i just meant in case you were planning on developing more facebook apps or something.

interesting re. zune. when it came out i thought it was too little too late, but ms seem to have done well on this one.
(Reply) (Parent) (Thread)
[User Picture]From: haran
2007-12-12 01:15 pm (UTC)
I've played around with silverlight (both - the javascript and python flavors) and on the whole, I'm impressed.

The installation process is painless.
Documentation and developer tools are good (as you would kinda expect from Microsoft).

From a purely technical standpoint, it kicks the crap out Flash.

Its main drawback will be overcoming the stigma of being a Microsoft product and, of course, the fact that Flash already has a solid user base.
(That latter point may not be much of an issue if Silverlight continues to be technically superior)
Linux support will be nice, but lets face it, thats not a show-stopper today.

(Reply) (Parent) (Thread)
[User Picture]From: arvindn
2007-12-12 04:17 pm (UTC)
yes. i've met people who won't touch it cuz its microsoft. i know people who won't touch it cuz they've spent the better part of a decade learning flash. definitely a lot of stigma going around.

linux support - well it's a show stopper for me :) i'm not about to switch my primary development environment.
(Reply) (Parent) (Thread)
[User Picture]From: mcfnord
2007-12-12 04:01 pm (UTC)
i work on silverlight, kinda. ok i work on wpf but my boss works on silverlight. 2.0 will be here before ya know it. If you use a dynamic language like Python, I think the user experience is simpler. But see they ditched 1.1 for 2.0 so really I don't remember what's going on.
(Reply) (Thread)
[User Picture]From: arvindn
2007-12-12 04:08 pm (UTC)
you do? you should blog about it :) i suppose they wouldn't like that though.
(Reply) (Parent) (Thread)
[User Picture]From: mcfnord
2007-12-12 04:29 pm (UTC)
actually i write on their blog but it's pretty square. today i'm probably going to put my silly code on there. it's a match game with words that blur in and out.
(Reply) (Parent) (Thread)