Archive
January, 2010
Browsing all articles from January, 2010
3

Let’s Go A Hunting

I wanted to draw a bunch of stick figure men carrying spears, going on a grand hunting event. There will be at least 15 men in the group. Of course I could draw them all by hand, but I decided to put my Photoshop Scripting abilities to good use.

people

I started with a drawing of three stick figure hunters. This drawing was made in Adoble Flash CS3 using a Wacom Bamboo tablet. Separating the legs from upper body gives me a set of 3 upper bodies and 3 pairs of legs. We can make 3X3=9 different hunters using these. The idea is very simple, match upper body with legs to form a member of the hunting group. I decided to randomly pick an upper body and a pair of legs to form each member of the group and keep looping until there isn’t space left on the image.

This is the script I wrote:

var defaultRulerUnits = preferences.rulerUnits
preferences.rulerUnits = Units.PIXELS

var imageWidth = 965 ;
var imageHeight = 150 ;

var legWidth = 60 ;
var legHeight = 75 ;

var torsoWidth = 75 ;
var torsoHeight = 150 ;

var nLeg = 3 ;
var nTorso = 3 ;

//open leg images
for(i=1;i<=nLeg;i++) {
	var fileRef = new File("C://hunt//leg"+i+".png");

	var docRef = app.open(fileRef);
	fileRef=null;

	docRef=null;
}

//open upper body images
for(i=1;i<=nTorso;i++) {

	var fileRef = new File("C://hunt//torso"+i+".png");
	var docRef = app.open(fileRef);

	fileRef=null;
	docRef=null;
}

var newDocument = documents.add(imageWidth,imageHeight);

//make some random hunters
for(j=0;j<17;j++) {

		app.activeDocument = app.documents[Math.floor(Math.random()*nLeg)];

		var AD = app.activeDocument;
		AD.artLayers[0].copy();
		app.activeDocument = newDocument;

		var layer = newDocument.paste();
		layer.translate(j*legWidth-imageWidth/2,legHeight);

		app.activeDocument = app.documents[3+Math.floor(Math.random()*nTorso)];

		AD = app.activeDocument;
		AD.artLayers[0].copy();
		app.activeDocument = newDocument;

		var layer = newDocument.paste();
		layer.translate(j*legWidth-imageWidth/2,legHeight/2+2);		

		layer.merge()

}

//close all files except for the final result
for(i=app.documents.length-2;i>=0;i--) {

	var AD = app.documents[i]
	AD.close(SaveOptions.DONOTSAVECHANGES);
}

preferences.rulerUnits = defaultRulerUnits;

And here is the result.

hunt

Since the hard part was already done, I decide to play around a little more and came up with this for a banner here. Hopefully It will stay there for a day :)

shikar1