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.

I started with a drawing of three [...]

Java Applet and Javascript message passing

I did this quite a while a ago, thought I should share this.
To call a js function foo from java applet :

String [] stringArgs = new String[2];

stringArgs[0] = "first arg from Java";
stringArgs[1] = "second arg from Java";

mainWindow.call("foo", stringArgs);

To call a function foo() in a java applet named bar, do the following in javascript:

document.bar.foo(param1, param2, ….) [...]

Photoshop Scripting : Hello World

Being respectful to traditions, let us start with a script for drawing “Hello World” in Photoshop. One can use Javascript or VBScript in windows or Applescript in Mac for photoshop scripting. The following Javascript code will produce a “Hello World” photoshop document.

var originalUnit = preferences.rulerUnits
preferences.rulerUnits = Units.PIXELS

// Create a new document
var docRef = app.documents.add( 300, [...]

Javascript: Getting Current Window Dimension

Javascript function to get current window height and width. Works with most of the browsers.
// function to get the current width of the window
function getWidth(){
var x = 0;
if (self.innerHeight){
x = self.innerWidth;
}else if (document.documentElement && document.documentElement.clientHeight){
x = document.documentElement.clientWidth;
}else if (document.body){
x = document.body.clientWidth;
}
return x;
}

// function [...]