gradientStops, their rampPoints, and gradientColor.angle
Hi,
Today marked my first attempts at Illustrator scripting; Illustrator's fairly new for me as well. Please tolerate my ignorance.
First, would some kind person out there explain why a gradient is only allowed two gradientStops, indexed [0] and [1] (otherwise, an out-of-bounds index error is thrown my way)? In a script I'd like to define and place several colors along a single gradient. How does one do this? I seem to be able to do this via Illustrator's Gradient window while not scripting.
Second, in CS5 has the gradientColor.angle bug been fixed? (See post at http://forums.adobe.com/message/1104567#1104567 from two years ago. Apparently this has been a problem for some time.) My CS4 version doesn't seem to do anything with this property.
Many sincere thanks. Before you ask, below is the script I've been playing with.
PAS
var myDoc = app.documents.add ( DocumentColorSpace.CMYK );
var myLayer = myDoc.layers.add ( );
var myTrianglePath = myLayer.pathItems.add ( );
var myPureCyan = new CMYKColor ( );
myPureCyan.cyan = 100;
myPureCyan.magenta = 0;
myPureCyan.yellow = 0;
myPureCyan.black = 0;
var myPureMagenta = new CMYKColor ( );
myPureMagenta.cyan = 0;
myPureMagenta.magenta = 100;
myPureMagenta.yellow = 0;
myPureMagenta.black = 0;
var myPureYellow = new CMYKColor ( );
myPureYellow.cyan = 0;
myPureYellow.magenta = 0;
myPureYellow.yellow = 100;
myPureYellow.black = 0;
var myGradient = app.activeDocument.gradients.add ( );
myGradient.type = GradientType.LINEAR;
myGradient.gradientStops[0].rampPoint = 0;
myGradient.gradientStops[0].midPoint = 30;
myGradient.gradientStops[0].color = myPureCyan;
myGradient.gradientStops[0].opacity = 100;
myGradient.gradientStops[1].rampPoint = 100;
// NONSENSICAL TO HAVE A SECOND MIDPOINT
// IF THIS IS THE FINAL PERMITTED GRADIENTSTOP
// myGradient.gradientStops[1].midPoint = 50;
myGradient.gradientStops[1].color = myPureMagenta;
myGradient.gradientStops[1].opacity = 0;
// MULTIPLE GRADIENTSTOPS NOT PERMITTED?
// myGradient.gradientStops[2].rampPoint = 100;
// myGradient.gradientStops[2].color = myPureYellow;
// myGradient.gradientStops[2].opacity = 100;
var myGradientFillColor = new GradientColor ( );
// GRADIENTCOLOR ANGLE ISN'T WORKING?
myGradientFillColor.angle = 45;
myGradientFillColor.gradient = myGradient;
myTrianglePath.setEntirePath ( [ [100,100], [500,100], [500, 700] ] );
myTrianglePath.stroked = true;
myTrianglePath.filled = true;
myTrianglePath.fillColor = myGradientFillColor;
