Over the last year, Alex and I have been practicing a bunch of acrobatic moves. With me lying on my back, he has been standing on my hands. I’ve been throwing him up in the air and catching him. And just this last week, we managed to nail his first somersaults. The picture below links to a (20MB) video clip of him doing backwards somersaults in our garden. I’m still giving him the initial boost, but just wait another year or two…
My Christmas rant
‘Tis the Season of Obligation, and I hate it.
If you’re feeling full of Christmas cheer and good will to all men, look away now, because reading this will only make you feel sad, angry, or insulted. Possible all three. I mean it. Really. Stop reading.
I love giving presents, but I hate giving them because the calendar says I must. I love my friends and family, but I hate having a massive list that we must methodically and mechanically run down to see that everyone receives at item appropriate to their status and closeness. And because everyone is buying presents all at the same time, I hate having to coordinate to ensure that the unwanted trinkets I plan to buy won’t clash with someone else’s purchase.
Likewise, I don’t care about getting presents for Christmas any more. I have everything I want already, and I would far rather you got me nothing than that you bought me something I don’t need and will never use just because you feel you have to. In fact, you know what’s the greatest gift you could get me next year? To tell me that you haven’t bought me anything. I would truly appreciate knowing that I have saved you that small measure of hassle, and that your Chistmas workload has been lightened just that little bit.
You think I’m kidding? You think I couldn’t possibly mean it? You think it’s just because the preparations for this Christmas have been getting me down? Absolutely not. I am being completely honest. Stop. Giving. Me. Shit.
(And please don’t give a charitable donation instead of getting me a gift. That’s just as bad. Give to a charity because you want to give to a charity, not because you feel some residual obligation to me. Charities need our money all year round.)
I have a wish list, and I hate not being able to buy anything from it in November or December, just because someone might selected something from it already. As of 2006, the wish list is going away.
If you really want to get me something, get something for ME–not for Christmas. If you have some music you particularly like, and you want to share it with me, send me a CD in the middle of March, out of the blue. If you’re browsing through the Autumn sales and see a T-shirt you think would suit me, give it to me in September. Show that it’s me you’re thinking about, not just another item on your shopping list.
I’m having a tough time keeping up appearances for the kids, and trying to keep things magical for them. I don’t want my grumpiness to ruin their pleasure. But equally, I don’t want them to grow up into Christmas Want-monsters. The American Thanksgiving tradition seems to me a much better model for a mid-winter holiday: the absence of gifts keeps things focused on the family, and the togetherness. There’s only so much preparation you can do for a big meal, and the shops don’t play psychosis-inducing festive music for two months solid leading up to it. (Honestly, the next time I hear “I Wish It Could Be Christmas Every Day” someone is going to get their nose bitten off.)
Finally, anyone who wants to call me a “Scrooge” can just fuck off. Get an original thought once in a while, you sheep.
Second best
If you’re feeling a bit technical, you might be interested in a new blog I’ve just started: Second Best. I’ll be using it as a place for writing about my professional interests, i.e. web standards, usability and accessibility, and software development.
If you don’t care, that’s okay, too.
S…l…o…w…
The more work I do inside Virtual Machines, the more I think my PC is coming ripe for an upgrade. An addional factor is the amount of Photoshop work I’ve been doing lately, including our annual photo albums.
For Christmas each year, Abi binds a set of albums, and we fill them with a selection of the best photos we’ve taken of Alex and Fiona. I don’t normally do much retouching of the images, but when Liza visited us earlier in the year, she enlightened me about the proper use of levels, curves, and colour balance. I’ve been practicing with these tools since then, and they are enormously useful. However, doing the photo albums is the first time I’ve used them for full-page, 600dpi print work. That means images of 6400 x 4100 pixels, and it doesn’t take too many of them to kill teh snappy.
So I’m pondering a few upgrades for Frankenstein:
- AMD Athlon64 X2 (dual core) processor. Dual core is gooood. The 4400+ is the sensible choice, I think. The 4800+ is too expensive for too little added benefit. The 3800+ is cheaper, but given that the 4400+ has both a speed bump and twice the L2 cache, the cost difference is probably worth it.
- Asus A8N-SLI SE motherboard. A new CPU means a new motherboard, unfortunately. This one supports all the features I need, and is reasonably priced.
- 256Mb Gigabyte PCI-E Geforce 6600 with SilentPipe (GV-NX66256DP). A mid-range card, because I’m not overly concerned about gaming performance (although it should certainly be good enough for another year or so). However, a chunky integrated heat sink allows it to run without a fan. Another option would be the higher-spec 256Mb Asus PCI-E EN6600GT-Silencer, but I’m not sure if it’s worth it. Given how I use the PC, less money on the graphics setup means more money to go on the CPU.
- 2GB DDR400 RAM. Lots of memory is gooood. 2GB would allow me to run several virtual machines at the same time.
Hmm. Next year…
Dynamically created (or included) Javascript
Dynamically created page elements? No problem. Dynamically created Javascript? As in, using document.createElement() to create a <script> element? Sounds like black magic, and it’s not something I would have tried myself until I saw the article @import voor JavaScript on Naar Voren (in Dutch). Basically, it’s a technique for giving Javascript the ability to include other script files “on demand,” much in the same way as PHP’s include() and include_once() functions.
This technique has actually been around for a while: a quick google showed me the article “Javascript includes – yet another way of RPC-ing”, by Stoyan Stefanov from July of this year, which in turn points back to articles from 2002. In addition to making the whole include() thing possible (a fantastically useful feature), using dynamically generated script also allows you to use make remote calls to other domains–something the HmlHttpRequest object forbids. In fact, Simon Willison was just talking about this the other day, in the context of Yahoo!’s web service APIs now providing output in JSON format as well as traditional XML.
It’s all coming together. A bundle of key techniques that have been around for ages (Unobtrusive javascript, object-oriented javascript, Ajax/remote scripting) have suddenly seen massive adoption and tremendous development. Javascript has matured a great deal over the course of 2005, and is rapidly tuning into one of the cornerstones of modern web development. It’s a very exciting time for the field.
Wiggle stereoscopy – a new approach
1. Introduction
If you’re never come across Wiggle Stereoscopy before, you should go straight over to Jim Gasperini’s web site. I first came across his images via BoingBoing a couple of years ago, but was reminded of it the other day by a link on Blog-Fu.
The technique gives an illusion of 3D by showing two images in rapid alternation: one from a left eye, and one from a right-eye perspective. Essentially it is separating the two pictures in time instead of space as is normally the case. You don’t need to wear special glasses to see the effect, and the illusion of dimensionality can be quite striking.
All of the 3D wiggle images I’ve seen on the web have either been animated GIFs, or Flash movies. These techniques have some disadvantages, though: animated GIFs are limited to a 256-colour palette, and using GIF compression for photos can result in large file sizes. Also, you need special programs to produce animated GIFs and Flash movies–you can’t just use plain ol’ Microsoft Paint.
However, I have come up with a new technique for showing wiggle stereograms on web pages, using only standard JPEG images, and a little sprinkling of Javascript. Using JPEGs gets around all of the limitations noted above, although it does introduce a few of its own. See for yourself if you think it’s worthwhile.
2. Wiggle it…with Javascript
The first step is to obtain a stereoscopic pair of photographs: two pictures of the same subject, taken a couple of inches apart. (I’ll describe how to make such a pair of photos with an ordinary digital camera in section 3.)

Next, using any graphics program you like, stitch these two pictures together side-by-side in a composite image of the same height, but exactly twice as wide as the originals. Then save this as a JPEG file.

In your web page, reference the composite image as you would any other picture, but give it a class attribute of “wiggle”:
<img src="http://www.sunpig.com/martin/images/2005/12/wiggle-alex-composite.jpg" class="wiggle" alt="Alex stereogram" />
Next, download the script file wiggle.js (version 1.2), and reference it in the head of your web page:
<head>
<title>Wiggly example<title>
<link rel="stylesheet" type="text/css" href="css/styles-site.css" />
...
<script language="javascript" type="text/javascript" src="js/wiggle.js"><script>
</head>
When executed, the wiggle script runs through the web page looking for images with the “wiggle” class. If it finds any, it replaces each one with a <div> element that is exactly half as wide as the composite image. It then uses the composite image as the background image for the <div>, so that you only see one half:

To perform the animation, the script simply switches the position of the background image every 120 milliseconds so that the visible part becomes hidden, and vice versa. (I chose 120 milliseconds because watching the effect at this speed felt right to me. There is no special significance to this frequency.)

Assuming you have Javascript enabled in your browser, the finished product looks like this:

Update (27 Dec 2005): Because of some problems with how Internet Explorer deals with background images, I have changed the underlying code slightly. Using the script is still just a matter of dropping it into your HTML page as described above, though. The new version (1.2) is available here.
The advantages of this method over using animated GIFs or Flash movies are:
- No additional software required. Any image program that produces JPEGs will do.
- You can use a full colour palette.
- The file size will generally be smaller than the equivalent animated GIF. How much smaller depends on the compression settings you apply to the composite JPEG.
The disadvantages are:
- It is Javascript-dependent. Without Javascript, you will just see the composite image, not the animation. This means that you won’t see the animation show up in any RSS feeds. Also, although I’ve tested it on modern versions of Firefox, IE, Opera, and Safari, the script will inevitably be incompatible with some browsers.
- If there are lots of animations on the page, of if your browser is taking up a lot of memory and/or CPU time doing other things, the animation may judder.
- Depending on your connection speed, you may see the composite images before the script kicks in and converts them to animations. There are ways around this, but for the benefit of simplicity, I’m presenting the wiggle script just the way it is.
Whether this trade-off is worth it, is up to you.
3. Some notes on taking stereoscopic pictures
It doesn’t take much hunting around on the web to find custom 3D camera solutions that you can either buy or build yourself. The traditional cheap-ass, lo-fi alternative is to find a stable resting point, and move your camera a couple of inches between snaps. However, if you have a camera with a high-speed continuous shooting mode, you have yet another option: hold the shutter button down, and let the camera take a stream of pictures while you gently move sideways.

Better, though, is to move the camera in a slight arc, so that you keep a central point in focus:

In ultra-high-speed continuous shooting mode, our Konica Minolta A200 takes 10 frames per second at a resolution of 640 x 480 (for up to 4 seconds). This produces up to 39 pairs of images (more if you also consider non-adjacent pictures), and often some of them are suitable for using as stereoscopic pairs. It’s not a particularly reliable method, but it’s an option. It can be quite useful if you’re trying to photograph moving targets (e.g. children) that are likely to zip half-way around the room in the time it takes you to reposition your camera for a second shot.
Keeping the camera moving in a graceful horizontal curve with no vertical travel is the really hard part. I’ve found that I get a steadier stream of images if I put the camera strap around my neck, and hold the camera out with both hands until the strap is taut: this stabilises the camera by anchoring it to my body, rather than just relying on my shaky hands.
Whichever method you use for getting your stereoscopic pairs, here’s a tip for producing images with the most striking 3D effect with the Wiggle technique. Try to capture a scene with three layers: foreground, centre, and background.
In the diagram below, points A and B are in the foreground, C is at the centre, and D and E are in the background.

When taking your pictures, try to angle the camera so that the central point stays fixed at the centre of the image:

By keeping the central point fixed, the foreground and background points will be parallax-shifted in opposite directions: the background will appear to have moved from left to right, and the foreground will appear to have moved from right to left.

In the image below, the trees and fence are in the background, the white rose is in the foreground, and the dying fuchsia bush is at the central point:

Having the foreground and background move in opposite directions seems to be key to the visual effect: your brain somehow perceives this as “correct”, and compensates appropriately for the lack of real dimensionality. Also, an object at the central point provides an “anchor” for the entire image. Stereoscopic pairs where the central point is unoccupied (even though, geometrically, it is still present in the picture) don’t seem to be quite as vivid.
4. Wrapping it up
I’ve had great fun playing with this technique over the weekend. I hope I’ve shown that producing this neato 3D effect can be done with nothing more than a digital camera and the basic graphics programs that are (most likely) built in to your computer’s operating system. If you decide to play about with it yourself, leave a comment below so I can come and have a look at your pictures!
