Copy link to clipboard
Copied
Hello,
Working from the great answer in this thread, I'm trying to move the center point of an object's gradient. Here's my test code:
var idoc = app.activeDocument;
var ipath = idoc.selection[0];
ipath.translate(
100, // deltaX
100, // deltaY
false, // transformObjects
false, // transformFillPatterns
true, // transformFillGradents
false // transformStrokePattern
);
Unfortunately, nothing I try actually works.
Anyone know what the trick is to move the origin of a radial gradient?
Thanks!
why didn't you use the code in that thread's great answer?
you left out a couple of vital lines
...// transform gradients findings
// select a path item with a gradient applied to it before running the script
var idoc = app.activeDocument;
var ipath = idoc.selection[0];
var fillcolor = ipath.fillColor;
ipath.filled = false; // remove previous gradient transformations, to be able to apply new ones ??
ipath.fillColor = fillcolor; // re apply the same gradient color, without transformations.
ipath.fill
Copy link to clipboard
Copied
why didn't you use the code in that thread's great answer?
you left out a couple of vital lines
// transform gradients findings
// select a path item with a gradient applied to it before running the script
var idoc = app.activeDocument;
var ipath = idoc.selection[0];
var fillcolor = ipath.fillColor;
ipath.filled = false; // remove previous gradient transformations, to be able to apply new ones ??
ipath.fillColor = fillcolor; // re apply the same gradient color, without transformations.
ipath.fillOverprint = ipath.fillOverprint; // without this, the gradient won't move or scale, but it does rotate ??
ipath.translate(
100, // deltaX
100, // deltaY
false, // transformObjects
false, // transformFillPatterns
true, // transformFillGradents
false // transformStrokePattern
);
Copy link to clipboard
Copied
Hi Carlos!
CarlosCanto wrote:
why didn't you use the code in that thread's great answer?
you left out a couple of vital lines
Good question.
I actually did use your code, which ended up working (the gradient I tested on was moved/skewed).
When I tried just moving (not skewing/scaling) nothing seemed to change (I tried both .translate and .transform). Sorry that I did not specify this in my original question.
Anyway, thanks so much for your reply and help! I will try your example code when I get home later today and let you know how it goes.
I really appreciate your help!
Cheers,
Micky
Copy link to clipboard
Copied
Hi Carlos!
Not sure if I am doing something wrong, but I can't seem to get this code to work:
#target illustrator
#targetengine main
var idoc = app.activeDocument;
var ipath = idoc.selection[0];
var fillcolor = ipath.fillColor;
ipath.filled = false; // remove previous gradient transformations, to be able to apply new ones ??
ipath.fillColor = fillcolor; // re apply the same gradient color, without transformations.
ipath.fillOverprint = ipath.fillOverprint; // without this, the gradient won't move or scale, but it does rotate ??
ipath.translate(
100, // deltaX
100, // deltaY
false, // transformObjects
false, // transformFillPatterns
true, // transformFillGradents
false // transformStrokePattern
);
Here's the file I am working on:
https://dl.dropboxusercontent.com/u/1277106/illy-gradient-offset.ai​
Can you tell if I am overlooking something?
The original script you posted does work (transform/skew), but it seems like translate doesn't work by itself. What do you think?
Thanks so much for your help, I greatly appreciate it.
Micky
Copy link to clipboard
Copied
are you bringing this shape from another application? it has some sort of appearance that is preventing the script from working. Use "Reduce to basic appearance" to clear it out, that will make the script work on your shape.
Copy link to clipboard
Copied
CarlosCanto wrote:
are you bringing this shape from another application? it has some sort of appearance that is preventing the script from working. Use "Reduce to basic appearance" to clear it out, that will make the script work on your shape.
Ahhh, great catch! Thank you so much for catching that.
I will try that tonight. Looks like copying all of the objects attributes, reducing appearance, re-applying gradient (like your script does) and then re-applying previous appearance is the direction I'll head.
I'll post back my findings soon!
Thanks so much Carlos! I really appreciate your help!
Copy link to clipboard
Copied
CarlosCanto wrote:
are you bringing this shape from another application? it has some sort of appearance that is preventing the script from working. Use "Reduce to basic appearance" to clear it out, that will make the script work on your shape.
That did the trick! I'm not sure what the appearance thing was. At one point I had rasterize applied to the top layer ... Anyway, reducing appearance did the trick.
Thanks a bunch for your help!!!!
Copy link to clipboard
Copied
you're welcome, glad to hear it worked
Copy link to clipboard
Copied
CarlosCanto wrote:
you're welcome, glad to hear it worked
Definitely!
In fact, here's the script that I created based on your original code:
GitHub - mhulse/illy-nudge: Nudge gradient centerpoint.
(Note: Only tested on my Mac)
Thanks again for all of your help!!!!! I really appreciate it.
Copy link to clipboard
Copied
it works great on Win10, CC2015, thanks for sharing!!
Copy link to clipboard
Copied
CarlosCanto wrote:
it works great on Win10, CC2015, thanks for sharing!!
Oh, cool!! That's good news. I wasn't sure if there would be any OS-specific things to consider.
Thanks for testing (and for all of your help too)!