Skip navigation
Currently Being Moderated

Quick way to create gradient from selected fill color?

Dec 14, 2012 5:08 PM

Tags: #gradients

I create gradients all the time and i'm wondering if there's a quick way to create a gradient based on the current selected object's fill color. For example: I have selected a box with a fill color of BLUE. I go to the gradient panel and see that what the gradient will be if I click on it (that is usally based on a default gradient WHITE to BLACK, or it comes from the most recent gradiented object I touched). So I click on it and the gradient is activated with the stops being not BLUE. What i want is... if i select a box with a BLUE fill and click on gradient - it will create a gradient with both stops being the same BLUE as the fill color. This would be very convenient because instead of clicking on each stop, shift-eyedropping the the blue color from a duplicated box, it would instantly start with the blue-blue gradient for me to tweak (in the case below for a button i would make the higher stop lighter and lower stop darker).

Screen Shot 2012-12-14 at 5.04.17 PM.png

 

It's somewhat useful to select an object with a gradient to "copy" that gradient, select a new object, click on the gradient panel and have this new object take on that exact gradient. But most of the time i'm not copying gradients but i'm creating new ones, and it makes more sense for me to create a gradient derived from the fill color. Would this be useful to anyone else?

 
Replies
  • Currently Being Moderated
    Dec 14, 2012 5:16 PM   in reply to thesergie

    It would be useful.

     

    Of course, you could always have 2 fills in the Appearance panel - a base color fill, then a gradient fill with transparency above the color fill. Then simply altering the color fill would retain the gradient. Could set this up as a Graphic style to quickly apply it.

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 14, 2012 6:19 PM   in reply to thesergie

    I do not think there is a way to do this. It is an excellent feature if it were implemented

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 14, 2012 8:14 PM   in reply to thesergie

    You bet this would be useful. I often build gradients based on percentages of the same color. This is closely related to my thread about editing gradients by dragging a swatch from the color panel.

     

    http://forums.adobe.com/message/4921421#4921421

     

    My workaround has been to have a simple 2-color default gradient, then select a filled objected and drag the color directly from the color panel to one of the gradient stops. Then drag the same color to the second stop. This works for both global and non-global colors in CS5, but only for non-global colors in CS6.

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 14, 2012 10:42 PM   in reply to thesergie

    Scott xuggested  graphic style but you can also set it up as a gradient swatch for both the swatch panel and for user defined gradient swatch for the swatch panel.

     

    Which as rcraighead suggested can be used like a template but i think it would be a better feature a new function for Illustrators gradients. Definitely a missing feature.

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 15, 2012 9:58 AM   in reply to thesergie

    I'm thinking about a workaround, but first off: Which version of Illustrator are you using?

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 15, 2012 12:07 PM   in reply to thesergie

    The following action is a prototype that currently just shows how you may automatise the task.

     

    Currently it requires a document that contains just one filled path and a gradient swatch (pure white to white) with the specific name "grad_white_white" (without quotation marks).

     

    Of course, the action could be modified, such that it would work in any document. Now, it just points to the principle.

     

    Note that the action has been recorded in AI CS 5. It may or it may not work in CS 6.

     

    https://docs.google.com/open?id=0B-IWkNSl4y_3NWdwaTdGcE56Yk0

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 15, 2012 2:22 PM   in reply to thesergie

    thesergie wrote: What i want is... if i select a box with a BLUE fill and click on gradient - it will create a gradient with both stops being the same BLUE as the fill color.

     

    As one possible alternative, you could create a script that gathers the selected object fill color values and creates a new gradient from this color, setting both the start and end gradient stops to this gathered color information, then it would apply this newly created gradient to the selected object.

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 16, 2012 12:44 AM   in reply to W_J_T

    this script does just that, it creates a gradient with both stops having the same color as the selected object

     

    var idoc = app.activeDocument;
    var sel = idoc.selection[0];
     
     
    var myGrad = idoc.gradients.add();
    myGrad.gradientStops[0].color = sel.fillColor;
    myGrad.gradientStops[1].color = sel.fillColor;
     
     
    var fillcolor = new GradientColor;
    fillcolor.gradient = myGrad;
    sel.fillColor = fillcolor;
    
     
    |
    Mark as:
  • Currently Being Moderated
    Dec 16, 2012 6:58 AM   in reply to CarlosCanto

    CarlosCanto, yep like that. It could additionally be added to prompt and give the gradient a name, as well as set a rotation angle, etc..

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 18, 2012 2:39 PM   in reply to thesergie

    thesergie wrote: How can I place this script into the File > Scripts list instead of having to always click "Other Script" and open it?

     

    Something along the lines of the following depending on your version...

     

    OS X: Applications/Adobe Illustrator CS5/Presets/en_US/Scripts

    Windows: C:\Program Files\Adobe\Adobe Illustrator CS5\Presets\en_US\Scripts

     

    thesergie wrote: Also, how do I set the rotational angle to 90 degrees (because most of my gradients are top to bottom instead of side to side)?

     

    var idoc = app.activeDocument;
    var sel = idoc.selection[0];
    var myGrad = idoc.gradients.add();
    myGrad.gradientStops[0].color = sel.fillColor;
    myGrad.gradientStops[1].color = sel.fillColor;
    var fillcolor = new GradientColor;
    fillcolor.gradient = myGrad;
    sel.fillColor = fillcolor;
    sel.rotate(90, false, false, true, false, Transformation.CENTER); // <--- For rotation
    
     
    |
    Mark as:
  • Currently Being Moderated
    Dec 18, 2012 11:22 PM   in reply to thesergie

    you're welcome, if you use it a lot, and I mean "a lot", consider creating an action to run the script, then you can run the action via hotkey. One minor drawback is, it will not survive a restart, you'll have to re-record it everytime you restart illustrator....but as I said, if you heavily use it, it will be worth the trouble.

     

    thanks for adding rotation W_J_T

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points