Neil's News

+ 2010
+ 2009
- 2008
 Polyglot 12: R
 Air Compressor
 Stanford CS145
 Retina
 Electoral College
 Obama vs McCain
 Perpetual Motion
 Book Safe
 Cráneo de Cristal
 Back to School
 Artificial Neuron
 Search Appliance
 Orthogonal Viewer
 Porcupine
 Bitmaps in JavaScript
 My Brain
 Domino Logic
 Faster is Better
 Transfer
 Car Fire
 Helsinki
 Jessa Gamble
 Maker Faire 2008
 Downhill Walker
 Youngme / Nowme
 Python Parallel Port
 MobWrite 2
 Class Clown
 Mask
 Progress
 Angel Island
 Scapegoat
 Localhost
 Disneyland
 Technical Difficulties
 Wooden Brain
+ 2007
+ 2006
+ 2005
+ 2004
+ 2003
+ 2002

Bitmaps in JavaScript

4 August 2008

JavaScript is good for many things, but drawing images has traditionally not been one of them. There have been several attempts: SVG[?], Canvas[?], table-based images[?]. But all three are extremely slow when drawing bitmaps.

I've found a new solution. Build a BMP image file in memory, Base64-encode it, and assign it as a data URI on an image tag. I wrote it as a joke then discovered to my horror that it was ten times faster than the other three options. The result is the JavaScript BMP Library. Check out the race between the different formats in the speed tests.

Note: If you want vector graphics, SVG and Canvas will win hands down. That's what they are designed for.

Update: I've simplified the API, stripped out the useless Canvas support, and created a dedicated speed test (now with SVG).


Randomness:

Co-worker: How do you clone an object in JavaScript?
Me: You have to sacrifice a small animal.
Co-worker: Oh, that's what I thought.

Was watching the SpaceX Falcon 1 launch live yesterday. Twice during the broadcast the video stream was interrupted and was replaced with this crash message (that's a view of SpaceX's desktop). Shortly afterwards the rocket crashed for real.

Next month an art gallery in Tel Aviv will be featuring my Youngme / Nowme photos. I've been told that the expression which made me look cute at one years old makes me look psychotic at thirty-four. Meh.

And finally, my Domino Domino Logic video sailed past 100,000 125,000 views (thanks in part to Boing Boing) and I'm hearing it is now being used in classrooms to teach the fundamentals of logic.

Update: Google Street View has released a group photo of Googlers. Including a bunch of people clutching pencils. Now you have a third data point to analyse against the previous two.

< Previous | Next >

 
-------------------------------------