• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Changing the angle of a linear gradient fill

Advocate ,
Feb 04, 2013 Feb 04, 2013

Copy link to clipboard

Copied

Hi friends

Suppose I have an object filled with a linear gradient. This object is the only selected. I just would like to change the angle of the gradient to 25 degrees. So I think I could do:

var doc = app.activeDocument

alert(doc.selection[0].fillColor.angle) // the result is the exact angle of the gradient fill of the selected object. Suppose 12 degrees.

//now the try to change:

doc.selection[0].fillColor.angle = 25.0

---

No errors are found by the Extended Script Toolkit..BUT...it does not change anything. As Illustrator reference manual does not say this property is read only, I think I could write.

Am I missing anything?

Thank you a lot for the help

Best Regards

Gustavo.

TOPICS
Scripting

Views

1.5K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Feb 04, 2013 Feb 04, 2013

It's tricky.

// GradientBlackWhite_rotated.jsx

// requires an open document and one selected object

var newGradient = app.activeDocument.gradients.add();

var colorOfGradient = new GradientColor();

var myGradientAngle = 80;

colorOfGradient.gradient = newGradient;

doc.selection[0].fillColor = colorOfGradient;

/*Thanx to John Wundes for this -->*/doc.selection[0].rotate(myGradientAngle, false, false, true, false, Transformation.CENTER);

redraw();

alert("gedreht");

Have fun

Votes

Translate

Translate
Adobe
Community Expert ,
Feb 04, 2013 Feb 04, 2013

Copy link to clipboard

Copied

It's tricky.

// GradientBlackWhite_rotated.jsx

// requires an open document and one selected object

var newGradient = app.activeDocument.gradients.add();

var colorOfGradient = new GradientColor();

var myGradientAngle = 80;

colorOfGradient.gradient = newGradient;

doc.selection[0].fillColor = colorOfGradient;

/*Thanx to John Wundes for this -->*/doc.selection[0].rotate(myGradientAngle, false, false, true, false, Transformation.CENTER);

redraw();

alert("gedreht");

Have fun

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Feb 05, 2013 Feb 05, 2013

Copy link to clipboard

Copied

LATEST

Thank you for the tip.

Will adapt this code to my needs

Thank you a lot

Best Regards

Gustavo.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines