TeamPhotoshop
Reviews, updates and in depth guides to your favourite mobile games - AppGamer.com
Forum Home Latest Posts Search Help Subscribe

Photoshop scripting

Page: 1 2 Reply
Jul 24th 2002#60522 Report
Member since: Jul 23rd 2002
Posts: 8
Okay, I'll give it a try.
Here's the script. It creates buttons with a dark and a light background. You'll need an additional action within photoshop that sets the color of the button. But if you can understand this script, you'll be able to figure that out. Good luck.



var aColors = new Array(3);
// sos blue
var aColor = new Array(3);
aColor[0] = "B2C3CC";
aColor[1] = "94B6C2";
aColor[2] = "C8DDE5";
aColors[0] = aColor;

// mystic green
var aColor = new Array(3);
aColor[0] = "A3BFB9";
aColor[1] = "88B6AB";
aColor[2] = "C5E3DD";
aColors[1] = aColor;

// havana brown
var aColor = new Array(3);
aColor[0] = "D0B5A0";
aColor[1] = "C59978";
aColor[2] = "EDD2BB";
aColors[2] = aColor;


var aDarkBGBtns = new Array(
"button 1"
, "button 2"
, "button 3"
);

var aLightBGBtns = new Array(
"button 1"
, "button 2"
, "button 3"
);

function OpenButton(mtype){
var fileRef = new File("e:/testdir/button_" + mtype + ".psd");
open (fileRef);
fileRef = null;
}

function CloseDoc(){
activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}

function SetText(txt){
activeDocument.layers["text"].textItem.contents = txt;
}

function SetBackGroundColor(clr){
var backColor = new SolidColor;
backColor.rgb.hexValue = clr;
activeDocument.activeLayer = activeDocument.layers["background"];
activeDocument.selection.selectAll;
activeDocument.selection.fill(backColor);
}

function SetButtonColor(clr){
var newColor = new SolidColor;
newColor.rgb.hexValue = clr;
doAction("color_"+clr,"SOS");
}

function SaveDoc(text,color,mtype,type){
var saveOpt = new GIFSaveOptions();
saveOpt.colors = 128;
saveOpt.transparency = true;
saveOpt.palette = Palette.LOCALADAPTIVE;
text = text.replace(" ","_");
if (type==0){
var newFile = new File("//testdir/test/" + color + "_" + text + "_" + mtype + ".gif");
} else {
var newFile = new File("//testdir/test/" + color + "_L_" + text + "_" + mtype + ".gif");
}
activeDocument.saveAs(newFile,saveOpt,true,Extension.LOWERCASE);
}

function DoButton(mtype,text,color,bgcolor,type){
OpenButton(mtype);
SetText(text);
SetBackGroundColor(bgcolor);
SetButtonColor(color);
SaveDoc(text,color,mtype,type);
CloseDoc();
}

function DoButtons(text,color,bgcolor,type){
DoButton("normal",text,color,bgcolor,type);
DoButton("down",text,color,bgcolor,type);
DoButton("over",text,color,bgcolor,type);
}

var btnColor = "";
var bgColorDrk = "";
var bgColorLght = "";
var subArr = new Array();
for (var j=0; j < aColors.length; j++){
subArr = aColors[j];
btnColor = subArr[0];
bgColorDrk = subArr[1];
bgColorLght = subArr[2];
for (var i=0; i < aDarkBGBtns.length; i++){
DoButtons(aDarkBGBtns[i],btnColor,bgColorDrk,0);
}
for (var i=0; i < aLightBGBtns.length; i++){
DoButtons(aLightBGBtns[i],btnColor,bgColorLght,1);
}
}
Reply with Quote Reply
Jul 24th 2002#60527 Report
Member since: Jan 19th 2002
Posts: 159
i will try out with that ...............

thanks for that

abhi
Reply with Quote Reply
Jul 24th 2002#60533 Report
Member since: Aug 9th 2001
Posts: 2333
Oh dear lord...all i see are letters mixed with numbers..
Reply with Quote Reply
Jul 24th 2002#60535 Report
Member since: Jul 23rd 2002
Posts: 8
Beware, this thread leads you into the twilightzone between designers-land and programmers-land...

Enter at your own risk ;)
Reply with Quote Reply
Jul 24th 2002#60544 Report
Member since: Jan 19th 2002
Posts: 159
okkey

abhi
Reply with Quote Reply
Jul 26th 2002#60822 Report
Member since: Apr 30th 2002
Posts: 98
I know javascript well, but I did not know you can use javascript to script in Adobe Photoshop. Why not XML?
Reply with Quote Reply
Jul 26th 2002#60864 Report
Member since: Jul 23rd 2002
Posts: 8
Scripting in Photoshop was available for the mac for a long time afaik. With the release of Photoshop 7 it now is available for windows as well. You can also use VB-script.
In order to use the scripting functionality, you'll need an optional plugin. That can be downloaded from the adobe site.

Why not XML? Because XML is a mere way of describing data, not programming it.
Reply with Quote Reply
Page: 1 2 Back to top
Please login or register above to post in this forum