Mar 272009
 

Today has thrown up some examples of what strange, dark times we live in.

Firstly the trailer for the live-action version of Where the Wild Things Are is released and turns out not to be a monumental travesty.

Then John Banks is quoted in the Herald saying something that I kinda-sortof-maybe actually agree with.

Has the world gone totally mad?

I am in a fragile state. If my expectations are shattered just once more today I may explode. All it would take is for me to find that the latest TV series from Japan is not incomprehensibly insane.



View at youtube.com

Phew! That was a close one!

Mar 262009
 

I have been quietly impressed with the progress web browsers have been making in recent years towards the goal of supporting a wide variety of applications. The promise of web-apps rivaling traditional desktop applications seems within reach after nigh-15 years of ballyhoo. Most recent browsers have extremely fast Javascript support and highly optimized DOMs, allowing a good level of interaction.

Of course, there a times when moving <div>s around just doesn’t cut the mustard. The canvas tag is not well used but is nothing less than a surface you can draw on using Javascript. It supports all the normal primitives (lines, arcs, fills, etc) and allows (indirect) access to the pixel data. While some people (eg: Project Bespin) are using the canvas tag in to offer extended functionality, I am busy fooling around.

Check out the fruit of my labour – Sketch This Page!.

It’s a Javascript bookmarklet that replaces each <img> element in a page with a same sized <canvas>. It works by copying the image to a temporary canvas, extracting the pixel data for some hacky post-processing, and then blatting the pixel-data onto the final canvas. The Javascript could certainly be better, but it works well enough and I am impressed with the speed.

The biggest flaw is that browsers will not allow Javascript to access the pixel data of images that are loaded from a different domain than the main page. This is a great idea from a security standpoint, but it does limit the usefulness of the bookmarklet. It would be great if Sketch This Page! worked on sites like Flickr, but sadly it is not to be.

For those interested, here is the function that actually dithers the image. I was going for a hatched look with the diagonal lines.

function generateBWDitherImage( src, dst )
{
   var srcContext = src.getContext(“2d”);
   var dstContext = dst.getContext(“2d”);

   var srcImageData = srcContext.getImageData(0, 0, src.width, src.height);
   var dstImageData = dstContext.getImageData(0, 0, dst.width, dst.height);
   
   for (var y = 0; y < dstImageData.height; ++y)
   {
      for (var x = 0; x < dstImageData.width; ++x)
      {
         var index = (dstImageData.width * 4) * y + (x * 4);
         var g = (0.30 * srcImageData.data[index]) +
             (0.59 * srcImageData.data[index+1]) +
             (0.11 * srcImageData.data[index+2]);
         if (g > 200)
         {
            g = 255;
         }
         else if (g > 150)
         {
            if (((y % 6) – x % 6) == 0)
               g = 0;
            else
               g = 255;
         }
         else if (g > 75)
         {
            if (((y % 4) – x % 4) == 0)
               g = 0;
            else
               g = 255;
         }
         else
            g = 0;
         dstImageData.data[index] = g;
         dstImageData.data[index+1] = g;
         dstImageData.data[index+2] = g;
         dstImageData.data[index+3] = 255;
      }
   }

   dstContext.putImageData( dstImageData, 0, 0 );
}

Mar 192009
 

I have quite a lot of books. I am not a book hoarder, I quite often do purges of books I don’t intend to read again, but my bookcases are always overflowing. I have tried various methods of keeping track of what I have read, but nothing really seemed that useful.

A friend at work just hipped me to LibraryThing, a website that seems tailor made for people like me. It is a little like a book-oriented facebook – you join and set up a profile (here is mine) and then start adding books. Books you have added can be given ratings and keywords, you can even write reviews if you are really keen. Once you have registered a few books, LibraryThing starts recommending other books you might like.

The website works pretty well for something claiming to be a beta. It is very text-heavy, but I don’t think that will be a problem for its target audience. The one thing that could be smoother is the interface for actually adding books – at the moment it is a bit of a pain to add multiple books by the same author, even if they appear together in the search.

In true Web2.0 fashion, LibraryThing offers all sorts of RSS feeds and blog widgets to publish data to other sites. As an experiment, I have added the LibraryThing widget to my blog theme. You should be able to see a random selection of books I have read to the right. I removed this, unfortunately it doesn’t work very well with my theme.

Mar 152009
 

The standard C++ iostreams library is very good (well, some would say sort-of good) at reading and writing a file’s contents, but it does so in such a way as to completely ignore file names. I am sure there was a good reason for this omission, but whatever it was is long out of date. There isn’t even a standard way to iterate through a directory, for God’s sake! You end up either falling back to the C standard library (ick) or using operating specific APIs just to find out how big a file is.
Continue reading »

Mar 132009
 

Apple has a new iPod out and that means a new version of iTunes. Along with support for the new device, there are a couple of interesting new features.

The first is autofill, a feature that I have been waiting for since I a got my first iPod. Up until now there has been no way to tell iTunes to simply fill up an iPod with music; you had to much around creating smart playlists and manually juggle how much space each one took up. Now you can just let iTunes fill the iPod from a playlist. It still isn’t as flexible as I would like (if I want to fill my iPod with 30% Scandinavian Death Metal, 40% Classical and the rest with 80s cartoon theme songs I see no reason why iTunes can’t accommodate me), but we now have the option.

iTune DJ Options Dialog

The second feature, iTunes DJ is an overhaul of the old Party Mix feature and is potentially awesome. Like Party Mix, it is basically shuffle on steroids, you select a playlist for your party and iTunes plays the songs. The interesting part is that it integrates in with the Remote iPhone/iPod Touch app. The allows you to mess about with the playlist from your portable device while your laptop is sitting on top of the stereo pumping out your cool tunes.

Even better, your guests can suggest upcoming songs and vote on what they want to hear next from their mobile devices. Luckily your guests can’t change the currently playing song, but everyone gets to have their say.

This will make iPhone/iPod Touch owners even more insufferable at parties, but frankly none of us care what you think. Count yourself lucky that we let you hang out with us in the first place.

Mar 102009
 

Watchmen is a difficult movie to categorize. As an adaption of an existing work, it is excellent. The attention to detail is amazing, the cast all fit well with their characters and an impressive amount of the plot is exactly the same. A for effort.

watchmenAs a stand-alone work, Watchmen is less of a success. It is very, very long and filled with talky scenes whose purpose only becomes clear later and sometimes not even then. It’s not that it is a terrible movie, just that a viewer not familiar with the source material might easily lose track of what is going on. So much of the plot hinges on the motivations of the characters – the book provides extensive back stories that the film cannot linger on, leaving the story feeling a little flat.

The production values are first rate, with excellent special effects. The actors are all look the part and for the most part are pretty good, except for guy playing Rorschach, who is excellent. Watchmen is an ensemble piece and the fact that none of the characters are played by major stars works to its advantage. The R rating is very well deserved, the film is quite gory in places and there is a lot of nudity. Watchmen may be the first mainstream film to have more male than female nudity, which I guess could be called some sort of landmark.

On the whole, I would recommend Watchman to anyone who enjoyed the book. I would still recommend it to others that enjoy the odd superhero film, but others will probably be bored.

Here endeth the review. The following section contains spoilers and crowing about how smart I am. Discerning readers may want to stop here – you have been warned.
Continue reading »

Mar 082009
 

Alright! This is the last one of these I am going to do, partly due to the time they take, but mostly because they make me look bad.

Fantasy is a much (and accurately) maligned genre. Unlike SciFi, Fantasy cannot pretend that its authors are offering up visions of our future, nor do novels containing doughty heroes slaughtering goblinoid lesser racers lend themselves to commentary on the human condition, except in the most ironic way. Still, I will admit to enjoying some olde-time dragon slayage as much as the next man.

I got this list from the same site as the SciFi list, but you can see they were scratching to find 100 fantasy books worth mentioning. Several items are more “Magic Realism” which is publisher-speak for “telepathic policeman” or some-such nonsense. Others are could have easily been labeled SciFi. Still more just aren’t really that good.
Continue reading »