我认为您正在寻找一种更改活动形状颜色的方法,在这种情况下,您可以使用此脚本侦听器代码:
var myHex = "003366";
//alert(hex_to_dec(myHex));
fill_rectangle(hex_to_dec(myHex));
function hex_to_dec(hexstring)
{
var hex = hexstring.match(/.{1,2}/g);
return [
parseInt(hex[0], 16),
parseInt(hex[1], 16),
parseInt(hex[2], 16)
]
}
function fill_rectangle(rgb)
{
var red = rgb[0];
var green = rgb[1];
var blue = rgb[2];
// =======================================================
var idsetd = charIDToTypeID( "setd" );
var desc23 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref3 = new ActionReference();
var idcontentLayer = stringIDToTypeID( "contentLayer" );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref3.putEnumerated( idcontentLayer, idOrdn, idTrgt );
desc23.putReference( idnull, ref3 );
var idT = charIDToTypeID( "T " );
var desc24 = new ActionDescriptor();
var idFlCn = charIDToTypeID( "FlCn" );
var desc25 = new ActionDescriptor();
var idClr = charIDToTypeID( "Clr " );
var desc26 = new ActionDescriptor();
var idRd = charIDToTypeID( "Rd " );
desc26.putDouble( idRd, red ); //red
var idGrn = charIDToTypeID( "Grn " );
desc26.putDouble( idGrn, green ); //green
var idBl = charIDToTypeID( "Bl " );
desc26.putDouble( idBl, blue ); //blue
var idRGBC = charIDToTypeID( "RGBC" );
desc25.putObject( idClr, idRGBC, desc26 );
var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );
desc24.putObject( idFlCn, idsolidColorLayer, desc25 );
var idstrokeStyle = stringIDToTypeID( "strokeStyle" );
var desc27 = new ActionDescriptor();
var idstrokeStyleVersion = stringIDToTypeID( "strokeStyleVersion" );
desc27.putInteger( idstrokeStyleVersion, 2 );
var idfillEnabled = stringIDToTypeID( "fillEnabled" );
desc27.putBoolean( idfillEnabled, true );
var idstrokeStyle = stringIDToTypeID( "strokeStyle" );
desc24.putObject( idstrokeStyle, idstrokeStyle, desc27 );
var idshapeStyle = stringIDToTypeID( "shapeStyle" );
desc23.putObject( idT, idshapeStyle, desc24 );
executeAction( idsetd, desc23, DialogModes.NO );
}