Dev

Making Context Free Art

If you are reading this post in your feed reader, you’ll want to click through to my actual website. Trust me on this one.

I was really impressed with Aza Raskin’s ContextFree.js experiment. I like how the simple rules of a context free art piece generate complex forms. See below, that text will turn into something I can’t exactly predict.
I’ve added a few comments to help you understand what’s going on there.

//all context free art starts with a single rule.  Ours will start with a rule named face.
startshape FACE
//and here is the rule FACE
rule FACE{
//a FACE rule means that we should draw the rules EYE MOUTH and HEAD.
 EYE{}
 // flip an eye over to the other side of the face.
 EYE{flip 90}
 MOUTH{}
 HEAD{}
}

//OH NO! We have two rules named HEAD.  Context free will randomly pick one
rule HEAD{ CIRCLE{}}
rule HEAD{  SQUARE{}}

rule EYE{CIRCLE { s .1 b .5 y .12 x .3}}
rule EYE {SQUARE { s .1 b .5 y .12 x .3}}
rule EYE {SQUARE { s .1 b .5 y .12 x .3 r 45}}
rule EYE {TRIANGLE { s .1 b .5 y .12 x .3}}
rule EYE {TRIANGLE { s .1 b .5 y .12 x .3 r 60}}

rule MOUTH {SQUARE{ s .8 .1 y -.12  b .5}}

And here is a randomly generated face, all made up of squares, circles, and triangles:

Want more faces? Go mess about with my face generator on Aza’s demo site.

update: in the comments Chris came up with a bunch of great mouths for an even better face generator!
The art is context free because any rule can be executed without knowing the context of the other rules - they are side-effect free. (these are the kind of problems that work well on lots of processors)
It gets much better. If you are using a modern browser, you’ll see that the heading of my website now is using this to generate random art up there in that previously wasted space.
Reload the website, you’ll see different art generated according to a handful of tiny algorithms. If you can see this, you might want to switch from Internet Explorer to Firefox or Safari. They both support the cool stuff that I’m doing, but you can’t see right now.

Art
Browsers
Design
Dev
Hacks
Pals
morelight

Comments (4)

Permalink

It’s all details

They say the devil is in the details. Sometimes subtle details are a place to shine.

I was reading notes on a lecture by the great Joshua Schachter, developer of Del.icio.us, when I was thunderstruck by a detail.

You have to speak the user’s language. “Bookmarks” are what you call them if
you use Netscape of Firefox - most users these days know the term “favourite”
instead. Half of his population (? users) didn’t know what a bookmark was.

It is true:
The small details matter

Browsers
Design
Dev
User Experience

Comments (0)

Permalink

The beauty of Ruby’s array subtraction operator

Today I had to a set of email addresses, one per line, from which I had to remove the addresses of folks that said “Don’t email me.” Those emails were in a separate file, one address per line.

I figured I’d have to do this again, so I wrote a ruby script to automate it. Below, stripper.rb

#put each address in an array, remove whitespace and make it all lowercase
 potential_emails = IO.readlines(”potentials.txt”).map! {|email| email.strip.downcase}
 delete_emails = IO.readlines(”donotemail.txt”).map! {|email| email.strip.downcase}

#use the beauty of ruby’s array subtraction operator
 puts potential_emails - delete_emails

Simple, terse and readable.  Lovely!

Dev
Ruby

Comments (2)

Permalink

Installing two firefox extensions at once

When I was working on AddArt for Steve at Eyebeam I figured out how to install two firefox extensions at once using a multiple install bundle xpi. Useful if you have an extension that is dependent on another extension.

Dev

Comments (0)

Permalink

The next language I learn will be processing


Solar, with lyrics. from flight404 on Vimeo.
This video was made with a language called processing and apparently it is the exclusive domain of pretty things. I like pretty things.

Animation
Dev
Music

Comments (0)

Permalink

Ramblings about add-art

Ignore this, it is just a braindump from the train.  Unless you want to help out.

I’ve started working on a project called add-art.   The idea is to turn advertisements into beauty.  It is based on the popular ad-block-plus firefox extension, but instead of leaving holes where advertisements are removed, it would insert art.  Curators could book shows on add-art.org for artists.  When you go to a website with tons of ads, they would be replaced by art images.

Great stuff!   Once we get the plugin working with add-art.org, we should look at decentralizing it.  Let the extension communicate with multiple ad block lists and multiple replacement image servers.  Then package the add-art.org server as an installable package so anyone can run it.  Let users pick up the url of other servers as a way to get art from the artists they like on their browser…

Deviantart might run something like this.
Maybe flickr/explore/interesting could be a provider.
Hell, why not use atom/rss as the provider and let any rss list of images be the provider?
Image sizing becomes an issue.  You need to stick in appropriate sized images.  If they aren’t the right size you’ll need to slice them up on the client side.  Is that cheap?  Does the browser give you a way to not only decently resize, but also slice from an image?

Art
Dev
Hacks
Software

Comments (0)

Permalink

Databind a ComboBox to an Enum and your business object

Databinding intelligently in .net is usually pretty easy. Recently I wanted to quickly bind a combobox where the items are the values of an enum made up of single words and the selected value is tied to my data object. I was surprised that it wasn’t all that straighforward. Here’s me saving you some time in the future.

What you want is an easy way to get a list of objects that you can bind the combobox to. Here is a list you can easily create from any enum that will give you a handle on the names and values of the enum.

code:

public class ComboEnumList <V> : List < keyvaluepair < string,V> >
where V: struct //at least we can constrain that it ain't a class
{
public ComboEnumList():base()
{
//because generics don't allow a constraint like "where V: enum"
if (!typeof(V).IsEnum) throw new Exception( "New Argument Not An Enum " + (typeof(V).FullName));
Array values = Enum.GetValues(typeof(V));
foreach (object value in values)
{
this.Add(new KeyValuePair(Enum.GetName(typeof(V),value), (V) value));
}
}
}

To use this, you’d inherit an instance of this class with type V = your enum.
code:

public class AvailableJerseyStyles : ComboEnumList
{}
public enum JerseyStyleEnum{
Stripes,
Diamonds,
Paisley,
CheckerBoard,
Houndstooth
}

Now go into the VS2k5 designer, add a new project data source based on your AvailableJerseyStylesClass. On instantiation, create the AvailableJerseyStyles object and set it as the datasource for your bindingsource. DisplayMemeber = “Key”, ValueMember = “Value”.
Bind the enum property of your business object datasource to the SelectedValue of the AvailableJerseyStylesClass and you are good to go.

Hope it helps.

Dev

Comments (0)

Permalink

Offline and online

Google came out with a good idea a while ago called Google Gears.  The idea is to make some of these new fangled web applications able to function when you aren’t connected to the internet.

It never seemed like that great of an idea to me, but I’ve been using a personal Wiki to track household stuff with my pardner Sam.  I’ve been wishing for a wiki that I could use when I’m on the train and away from the internet.

I love the network.  When you are away from it though, why couldn’t you have a better cache - a mini net that is the last known version of what you seem to care about.  I’ve been using programs to download entire websites locally so I can read them while I commute.  It would be nice if you could just mark them as being of special interest in your browser.  Let computers hum and whir and keep it all up to date and in synch.  If we can do it with email, could we do it with the web, or at least the web I’m interested in?

Some folks think that offline and online will disappear as the network penetrates every corner of the world.  I doubt it.  Someone’s got to pay for it. More folks are interested in drinking water than BoingBoing, but it hasn’t penetrated every corner of the world.

Design
Dev
Get.rich.quick
Hacks

Comments (0)

Permalink

More on the awesomeness of VIM

Nate wrote a bit on it. And then I watched this google video presentation by the VIM Guy himself, Brad Moolenaar.

I hadn’t known this, but CTRL-N is great. As soon as you are typing something you’ve typed once before, CTRL-N to the rescue. It autocompletes anything!

Dev
Hacks
Vim

Comments (0)

Permalink

PDF Wallet Generator

I’ve completed work on the pdf wallet generator and put up some notes on the work under projects.

Dev
Hacks
Software

Comments (0)

Permalink

Bad Behavior has blocked 213 access attempts in the last 7 days.