Skip to main content
Known Participant
August 1, 2011
Answered

[CS5] [JS]-Gradient Feather with Gradient Stops Question

  • August 1, 2011
  • 1 reply
  • 1318 views

Hello,

Have any of you ever scripted applying a Gradient Feather with Opacity Gradient Stops. If so, I would appreciate you assistance. I'm trying to apply multiple effects to objects. I can apply the gradient feather but I am having issues with the stops.

//Inner Glow settings from milligramme var obj=app.activeDocument.selection[0]; $.writeln(obj.transparencySettings.innerGlowSettings.properties.toSource().replace(/,/g,",\n")); with (obj.transparencySettings.innerGlowSettings){   applied = true;   blendMode = 1852797549/*BlendMode.NORMAL*/;   opacity = 100;   noise = 0;   effectColor = "Paper";   technique = 2020618338/*GlowTechnique.PRECISE*/;   spread = 79;   size = '0.125in';   source = 2020618594 /*InnerGlowSource.EDGE_SOURCED*/;  } //Directional Feather settings, based off milligrammes script var obj=app.activeDocument.selection[0]; $.writeln(obj.transparencySettings.directionalFeatherSettings.properties.toSource().replace(/,/g,",\n")); with (obj.transparencySettings.directionalFeatherSettings){   applied = true;   angle = 46;   noise = 0;   chokeAmount = 49;   followShapeMode = FollowShapeModeOptions.ALL_EDGES;   bottomWidth = '0.25in';   topWidth = '0.125in'   rightWidth = '0.6in'   leftWidth = '0in' } // Gradient Feather Settings, PLEASE HELP var obj=app.activeDocument.selection[0]; $.writeln(obj.transparencySettings.gradientFeatherSettings.properties.toSource().replace(/,/g,",\n")); with (obj.transparencySettings.gradientFeatherSettings){   applied = true;   angle = 90;   type = 1635282023/*GradientType.LINEAR*/; // GradientStop settings go here???????   }

I am not grasping how I am supposed to get the values of the Gradient stops into the script. If you can help me with this, you can use any stop settings you have. Any help would be greatly appreciated.

Thank you very much,

Danny

This topic has been closed for replies.
Correct answer milligramme

Hi

GradientStop can access via.

obj.transparencySettings.gradientFeatherSettings.opacityGradientStops

it is collection of OpacityGradientStops.

with (obj.transparencySettings.gradientFeatherSettings){   applied = true;   angle = 90;   type = 1635282023/*GradientType.LINEAR*/;   // GradientStop settings go here???????   with(opacityGradientStops){     // by default, it has two stops     for (var i=0, iL=opacityGradientStops.length; i < iL ; i++) {       $.writeln(opacityGradientStops.properties.toSource());     };     // you can edit     opacityGradientStops[0].opacity = 0;     opacityGradientStops[1].opacity = 100;         // you can add a gradient stop, but add at end of collection     // so remove last stop, and add again     // do you have any nice idea?     opacityGradientStops[1].remove();     var mid_op_grad_stop = opacityGradientStops.add({       opacity:50,       location:50,       midpoint:50,     });     var last_op_grad_stop = opacityGradientStops.add({       opacity:100,       location:100,       midpoint:50,     });   } }

Thankyou

mg.

1 reply

milligramme
milligrammeCorrect answer
Inspiring
August 2, 2011

Hi

GradientStop can access via.

obj.transparencySettings.gradientFeatherSettings.opacityGradientStops

it is collection of OpacityGradientStops.

with (obj.transparencySettings.gradientFeatherSettings){   applied = true;   angle = 90;   type = 1635282023/*GradientType.LINEAR*/;   // GradientStop settings go here???????   with(opacityGradientStops){     // by default, it has two stops     for (var i=0, iL=opacityGradientStops.length; i < iL ; i++) {       $.writeln(opacityGradientStops.properties.toSource());     };     // you can edit     opacityGradientStops[0].opacity = 0;     opacityGradientStops[1].opacity = 100;         // you can add a gradient stop, but add at end of collection     // so remove last stop, and add again     // do you have any nice idea?     opacityGradientStops[1].remove();     var mid_op_grad_stop = opacityGradientStops.add({       opacity:50,       location:50,       midpoint:50,     });     var last_op_grad_stop = opacityGradientStops.add({       opacity:100,       location:100,       midpoint:50,     });   } }

Thankyou

mg.

Known Participant
August 2, 2011

Thank you!