When art and programming collide

You know what I do on my days off? I work some more. Okay, no, not literally, but I do kind of tend to play around with work-related stuff.

I just discovered something awesome about Photoshop CS5 a couple hours ago when snuffling around in the help files like a truffle pig: data driven graphics. At first, I was a bit puzzled because that really doesn’t sound like a very artsy kind of thing, but it piqued my inner programmer’s curiosity. Turns out that you can basically turn a PSD file into a template, load variables from a text file, and use those variables to do things like change text layers, replace pixels, and hide/show layers.

Of course, I had to give it a try, and after some brief thought, I hit upon the idea of using this functionality to rapidly generate a large number of unique license plates for the Brio, Interceptor, and other vehicles. So, I saved out copies of the Interceptor textures, then cropped them down to just the license plate frames, deleted all superfluous layers, and turned them into license plate templates.

I set them up so I could change the country code and plate text layers on the UK and European plates, and the North American test plates had 4 configurable layers (month of registration, last 2 digits of registration year, serial, and locality). No real reason, I just wanted to see if I could do it.

With the artistic half completed, it was time for the programming bit. I didn’t want to waste my time manually entering license plate data over and over when I could just randomly generate a large amount of data and dump it to a text file that could be loaded in Photoshop. So, I whipped up a rough PHP script and fired up my local install of EasyPHP.

License plates tend to follow a pretty specific format, so it’s not like you can just generate random strings and be done with it. I wrote the script to take a formatting template as input, so I could specify a formatting template like “111-aaa” (3 random numbers, hyphen, 3 random letters), “AA11 AAAA” (2 random alphanumeric characters, 2 random numbers, space, 4 random alphanumeric characters), and so forth. That was fun to do.

I realized shortly after a few rounds of testing that I could literally do any license plate in the world in mass quantities with relatively little work, and it would pretty much only require a different template and formatting string. So, pretty soon, I’m going to be setting up my very own Department of Motor Vehicles next door to Uppity Robots and Ebbles Variations, where you guys can download sheets of unique stick-on license plates for that little bit of extra flavor.

Speaking of which, just for grits and shiggles: here’s a sheet of 570 (yes, that’s not a typo) unique North American-style license plates that I did as a test: licenseplates_test.zip

That’s just a few minutes of hands-on work! All I did was press a few keys, click a few buttons and all of the grunt work was done by Photoshop, Bridge, and OpenOffice.

I’m gonna be modifying the script a bit to randomize the registration date and locality variables for that little extra touch of uniqueness, and also refactoring the data set generation script so I can quickly modify new copies of it to generate plates for a specific country.

Yeah, this is all a bit silly, but it was fun to do, and I don’t often get to exercise both of my core skills at the same time like this.

UPDATE: Here it is! Department of Motor Vehicles

7 thoughts on “When art and programming collide

  1. Anonymous

    Mel, I love your Police car! It reminds of the Space Pollice ships in "Space Truckers"! Thanks for the UK scheme on one variant – it seems almost churlish of me to point out that the "Battenburg" scheme is for the county forces, the Metropolitan Police (who police Greater London) use this scheme:

    http://www.youtube.com/watch?v=TDz-0jEUJds

    of fluorescent stripe – oddly enough, I've found one site that shows a "Met" Police car with Battenburg! Still, the red-and-yellow-stripe livery is what the cops around my part of South London use.
    Looking forward to the release,
    Grif

  2. glenn williams

    OK, this really means you need to get out more. Take a bottle of wine, a blanket, the Mrs, and find some trees.

    And . . . yeah . . that's really cool stuff. I am always envious (my last real programming was in GPSS and SIMSCRIPT).

  3. Christopher Roe

    WW8: Yeah. What can I say?

    Grif: This is the future, and the Battenburg livery looks more spacey than the orange stripe dealie. Also, the scheme was designed for motorway/trunk road police, so it seemed appropriate for a high speed pursuit/response vehicle like the Interceptor. 🙂

    Glenn: Heh. 🙂

    Tommygun: Best thing I like about it? No lines or surly bureaucrats.

  4. Vermin King

    And I'm assuming that you could do the same thing with the car numbers, too, right? That would be amazing

Leave a Reply

Your email address will not be published.