How to change the angle of a gradient layer without changing anything else?

How to change the angle of a gradient layer without changing anything else?
When I try it myself my whole gradient turns black.

To add to the above, you can not just set the angle. If you want to use other existing settings you need to get them from the layer. The code in that other thread shows one way to get them.
But if you do not need the existing values for any other reason you can get the descriptor for the layer, make a duplicate of it with all the settings and just overwrite the ones you want to change.
This is one way to just change the angle while keeping the other existing settings.
// helper function for working with descriptors
function getProperty( psClass, psKey, index ){// integer:Class, integer:key
    var ref = new ActionReference();
    if( psKey != undefined ) ref.putProperty( charIDToTypeID( "Prpr" ), psKey );
    if(index != undefined ){
        ref.putIndex( psClass, index );
    }else{
        ref.putEnumerated( psClass , charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
    try{
        var desc = executeActionGet(ref);
    }catch(e){ return; }// return on error
    if(desc.count == 0) return;// return undefined if property doesn't exists
    var dataType = desc.getType(psKey);
    switch(dataType){// not all types supported - returns undefined if not supported
        case DescValueType.INTEGERTYPE:
            return desc.getInteger(psKey);
            break;
        case DescValueType.ALIASTYPE:
            return desc.getPath(psKey);
            break;
        case DescValueType.BOOLEANTYPE:
            return desc.getBoolean(psKey);
            break;
        case DescValueType.BOOLEANTYPE:
            return desc.getBoolean(psKey);
            break;
        case DescValueType.UNITDOUBLE:
            return desc.getUnitDoubleValue(psKey);
            break;
        case DescValueType.STRINGTYPE:
            return desc.getString(psKey);
            break;
        case  DescValueType.OBJECTTYPE:
            return desc.getObjectValue(psKey);
            break;
        case  DescValueType.LISTTYPE:
            return desc.getList(psKey);
            break;
        case  DescValueType.ENUMERATEDTYPE:
            return desc.getEnumerationValue(psKey);
            break;
function duplicateDescriptor( descriptor ) {
    var newDescriptor = new ActionDescriptor;
    newDescriptor.fromStream( descriptor.toStream() );
    return newDescriptor;
function localizeDescriptor( desc ) {
    var stream, pointer, zStringLength, zstring, localized_string, newZStringLength, previousStream, followingStream, newDesc;
    stream = desc.toStream();
    while( true ) {
        pointer = stream.search(/TEXT....\x00\$\x00\$\x00\$/);
        if( pointer === -1 ) {
            break;
        zStringLength = getLongFromStream( stream, pointer + 4 );
        zstring = readUnicode( stream.substr( pointer + 8, ( zStringLength - 1 ) * 2) );
        localized_string = ( localize( zstring ) ) + '\u0000';
        newZStringLength = localized_string.length;
        previousStream = stream.slice( 0, pointer);
        followingStream = stream.slice( pointer + 8 + zStringLength * 2);
        stream = previousStream.concat( 'TEXT', longToString( newZStringLength ), bytesToUnicode( localized_string ), followingStream );
    newDesc = new ActionDescriptor();
    newDesc.fromStream( stream );
    return newDesc;
function getShortFromStream( stream, pointer ) {
    var hi, low;
    hi = stream.charCodeAt( pointer ) << 8 ;
    low = stream.charCodeAt( pointer + 1 );
    return hi + low;
function getLongFromStream( stream, pointer ) {
    var hi, low;
    hi = getShortFromStream( stream, pointer) << 16;
    low = getShortFromStream( stream, pointer + 2);
    return hi + low;
function readUnicode( unicode ) {
    var string = "";
    for( i = pointer = 0; pointer < unicode.length; i = pointer += 2) {
        string +=String.fromCharCode( getShortFromStream( unicode, pointer ) );
    return string;
function longToString( longInteger ) {
    var string;
    string = String.fromCharCode( longInteger >>> 24 );
    string += String.fromCharCode( longInteger << 8 >>> 24 );
    string += String.fromCharCode( longInteger << 16 >>> 24 );
    string += String.fromCharCode( longInteger << 24 >>> 24 );
    return string;
function bytesToUnicode( bytes ) {
    var unicode = "", char_code, charIndex;
    for( charIndex  = 0; charIndex < bytes.length; charIndex ++ ) {
        char_code = bytes.charCodeAt( charIndex );
        unicode += String.fromCharCode(char_code >> 8 ) +  String.fromCharCode( char_code & 0xff );
    return unicode;
function setGradientAdjustmentAngle( angle ) {
    var adjustmentDesc = getProperty( charIDToTypeID("Lyr "), charIDToTypeID( 'Adjs' ) ).getObjectValue(0);
    var newAdjustmentDesc = duplicateDescriptor( adjustmentDesc );
    newAdjustmentDesc.putUnitDouble( charIDToTypeID('Angl'), charIDToTypeID('#Ang'), angle );
    var desc = new ActionDescriptor();
        var ref = new ActionReference();
        ref.putEnumerated( stringIDToTypeID('contentLayer'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
    desc.putReference( charIDToTypeID('null'), ref );
    desc.putObject( charIDToTypeID('T   '), stringIDToTypeID('gradientLayer'), newAdjustmentDesc);
    executeAction( charIDToTypeID('setd'), desc, DialogModes.NO );
var newAngle = 45;
setGradientAdjustmentAngle( newAngle );

Similar Messages

  • In Lion 10.7.x I cannot disable the Lock documents for 2 weeks in Time Machine! Thus it prevents to change anything else like the system preferences or other settings. How I can disable it?

    Hello, In Lion 10.7.x I cannot disable the Lock documents for 2 weeks in Time Machine! Thus it prevents to change anything else like the system preferences or other settings. All is locked. How I can disable it?

    Do you mean the check box isn't enabled?
    Or you remove the check but it doesn't "stick"?
    Or you remove the box but documents are stil getting locked?
    That setting doesn't apply to other things in System Preferences, just apps that support AutoSave and Versions.  If you're having a problem with System Prefs, please clarify exactly what.

  • How to delete the last element of a collection without iterating it?

    how to delete the last element of a collection without iterating it?

    To add to jverd's reply, even if you could determine the last element, in some collections it is not guaranteed to always be the same.
    From HashSet:
    It makes no guarantees as to the iteration order of the set; in particular, it does not guarantee that the order will remain constant over time.

  • How to share the Mac folder to open windows without password?

    como compartilhar pasta do mac para abrir no windows sem senha?
    how to share the Mac folder to open windows without password?

    No easy way. Unless you use the same username and the same password on both system then you have to enable Windows File Sharing (SMB) in Sharing, add your Mac username and type in your password in the options of Sharing and then set a NetBIOS name and a workgroup name that is the same on both Windows and Mac. That is in the Network section under advanced WINS tab.

  • I have the ESPN ScoreCenter app on my iPhone 4S and since I installed iOS7 I am no longer receiving alerts for my teams.  I have not changed anything else, Notifications is on all my team alerts are on.

    I have the ESPN ScoreCenter app on my iPhone 4S and since I installed iOS7 I am no longer receiving alerts for my teams.  I have not changed anything else, Notifications is on, all my team alerts are on.

    Wow, just posting and it seems that there is a solution that is working for me...
    What I've did is I turned off iTunes Match on my iPhone, then turned in on again. Now in my iTunes library on my mac I can get the duplicates to be matched or uploaded to iCloud with a right-click, add to iCloud. iTunes Match starts to check the songs and everything is done correctly. Pretty nice!

  • How to disable the trackpad while typing on mbp without mouse ?

    how to disable the trackpad while typing on mbp without mouse ?

    Like Kappysaid :
    Kappy wrote:
    Open Universal Access preferences. Under either the Keyboard or Mouse tab should be a checkbox option to prevent accidental input when typing. If you don't find it there then check in the Trackpad preferences.
    or find the apple instructions here http://support.apple.com/kb/HT3608
    Good luck

  • My iTunes was working fine, all my CDs would import fully and quickly. Now they are importing slowly and when the CDs get to the last track they don't import and the CD drive just keeps spinning without doing anything! How can I fix this?

    My iTunes was working fine, all my CDs would import fully and quickly. Now they are importing slowly and when the CDs get to the last track they don't import and the CD drive just keeps spinning without doing anything! How can I fix this?
    I don't want to have to restart or reinstall my iTunes again as I'll have to redo all my playlists etc

    Likely that CD then. Check visually for damage, blemishes, etc., not that there's anything you can really do about those other than return the CD.
    The drive sits there and spins because it is trying to re-read the CD.  iTunes has error correction which is contributing to all this re-reading, I believe, and you may be able to disable that in preferences if you aren't picky about the result.
    You can also try other rippers such as Max or XLD.  I know those have configurable error correction.  I like XLD but it is slightly tricky to use until you find that for some reason the author has put all settings under preferences, not just the set once and forget ones.

  • I bought two films on my ipod tough 4g ( normally comes up on my ipad if i have bought something on my ipod) but i dont know how to get the two films on my ipad without paying for them.

    I bought two films on my ipod tough 4g ( normally comes up on my ipad if i have bought something on my ipod) but i dont know how to get the two films on my ipad without paying for them.

    Movies work differant than TV shows, music and apps. With movies, to get them from one device such as an iPod Touch to an iPad, you would need to connect the Touch to your computer first and in iTunes under the file menu, hit transfer purchases. Next connect the iPad and you can sync the movie to the iPad.
    While the iPad is connected to the computer, in iTunes, click on the iPad in the left pane and when the screen loads, click movies and from there, you can select the movie that you want to sync.

  • How can I reinstall Safari 8.0 without disturbing anything else?

    How can I reinstall Safari 8.0 without disturbing anything else?  I have OS X 10.10.1 Yosemite & Safari 8.0 (that comes in it) installed on a MacBook Pro laptop and a Mac Mini tabletop computer. I want to access internet banking which goes without problems on the laptop but does not work on the tabletop. The latter says "somebody tried to display the application in a frame..." whatever that means and obviously for safety reasons I can not start banking it always comes back to the screen with this warning. I tried Mozilla FireFox on the tabletop Mini and everything works fine including the banking. A Mac expert suggested something is wrong with the Safari settings and I should reinstall it. How do I do this without reinstalling the System? Would it suffice to wipe out the Safari Preferences and start anew? I am looking for somebody's advice more experienced than I am. Thanks! 
    Andy

    Hello isza41,
    Before you try to do any uninstall/install stuff let me suggest you something:
    Create a new user and check if the same happens within its account. You could do so by going trough the following steps:
    Choose Apple menu > System Preferences, then click Users & Groups.
    Click the lock icon to unlock it, then enter an administrator name and password.
    Click Add below the list of users.
    Click the New Account pop-up menu, then choose a type of user. - Standard user account would be perfect here.
    Enter a full name for the new user. An account name is generated automatically. To use a different account name, enter it now—you can’t change it later.
    Enter a password for the user, then enter it again to verify. Using a password hint is recommended to help the user remember his or her password.
    Click Create User.
    Now Logout from your account (⌘⇧Q) and Login to the one you have just created. This account is fresh without any changed settings(as a new instance would look like).
    Check if the same would happen and you would see if this is an issue with your installation or something more general.

  • I have read the various threads regarding slow boot up times, on my 2009 MBP it takes 1 minute to get a usable interface but without doing anything else the HD is active for a further minute, is this reasonable ?

    My MBP after the Lion upgrade takes 1 minute to put something usable on screen and without doing anything else the HD is active for another minute.
    I have visited the Genius bar where they went through some maintenance routines and permissions repaired etc but the boot up time remains the same.
    I have cleared the cache as suggested in other threads but is this the best I can expect as with SL the computer booted up in about 30 seconds ?
    I recall reading there may be unwanted  programs loading at boot up time but I do not know where to look in the system to check.

    Thanks for the reply, I have followed your suggestion but unfortunately it has not improved the boot time, do you have any further advice you could offer me ?
    I use my MBP for working on and storing my photographic images following my Photoshop adjustments, these individual image files are between 50 to 60Mb, I was reading about OSX self defragmenting files below 20Mb, these files are not intended as start up items but do you think storing approx 200Gb of these files could be having so effect ? I am a fromt end user so my limited knowledge is restricted to repairing permissions etc. I am probably clutching at straws but it be better to store these images on an external HD in addition to my backups on other HD's.
    Thanks.

  • I have attempted to install iTunes multiple times but to no avail. I have installed every file, and followed every instruction on the support pages. I click download, and it takes me directly to the "Thank You for Downloading" page without doing anything.

    I have attempted to install iTunes multiple times but to no avail. I have installed every file, and followed every instruction on the support pages. I click download, and it takes me directly to the "Thank You for Downloading" page without doing anything. I am running it on FireFox, and I have tried with Internet Explorer, neither have worked. I have been trying to do this for weeks now, and I am getting majorly frustrated. Please, help.

    Perhaps try downloading and saving a copy of the installer to a different PC. (If you're on a 32-bit Windows system, try to download on a different 32-bit Windows system.) Copy the iTunesSetup.exe installer to an external hard-drive, or a large-enough thumb drive or burn it to a CD-R. Carry the installer back to your PC, copy the installer to your hard drive. (Don't run the install from the ExHD, thumb or CD-R.) Start the install by doubleclicking the iTunesSetup.exe file.

  • I tried to update my ipad3..now I have the dreaded red bleeping screen of death... it is literaly bleeping on and off. I can't turn the ipad off and I can't do anything else either. Any thoughts?

    it is literaly bleeping on and off. I can't turn the ipad off and I can't do anything else either. Any thoughts?
    I plugged it into my laptop and it still doesn't do anything but blip red.
    I knew I should have waited to up date it until I got back. everytime i try to update one of my ipads, something goes wrong.....
    I really need my ipad back as I am going on a trip tomorrow morning and need my gps map on there.

    I held down the sleep and home key to shut down the ipad.... it's restarting...hopefully this will work!

  • Is there a way of grabbing the name of a shape layer without referring to it specifically?

    similar to 'thisLayer.name', is there a way of being able to grab the name of a shape layer without referring to it specifically?
    I'm wanting something like 'thisShape.name' rather than having to define it as content("this shape name")
    Any help with this would be greatly appreciated!
    thanks

    Thanks for replying Dan, you're right, I should provide more context.
    I want to be able to duplicate a shape inside a layer a number of times, and with every duplicated shape, I want that shape to evaluate what number it is (based on a name I give it so I could name it '1' and then use something like 'eval(propertyname)' to return a number or perhaps use an index to count the number of shapes in the layer) and multiply that number by some set of rules that I can define and control through a list of expression controls on another layer. This would allow me to duplicate a square 10 times and have each square's position do something like
    x = thisShapeNumber + shapeLength * TranslateExpressionControl;
    y = 0;
    [x,y]
    which would form a long line of squares for instance. Does that make sense?
    thanks in advance!

  • Using applescript how do I set the angle of a gradient

    Using Applescript I need to set the angle of the gradient to 90 degrees. I've tried everything I can see in the scripting guide.
    This is a sample of the script I'm using to set the gradient all I need to know is where and how to set the gradient to horizontal. Please forgive me as I'm a real newbie at this!!!
    tell application "Adobe Illustrator"
        activate
        make new document
        set ellipseRect to {100, 100, 500, 500}
        set ellipseColor to {cyan:0.0, magenta:100.0, yellow:100.0, black:0.0}
        set myellipse to make new ellipse at beginning of current document with properties {bounds:ellipseRect, inscribed:true, reversed:false, stroke color:ellipseColor, fill color:ellipseColor}
        set Doc_Ref to the current document
        tell Doc_Ref
            if not (exists gradient "My Gradient") then
                set This_Gradient to make new gradient at end with properties ¬
                    {name:"My Gradient", gradient type:linear}
                set properties of gradient stop 1 of This_Gradient to ¬
                    {midpoint:50, ramp point:0.0, color:{cyan:0, magenta:50, yellow:100, black:0}}
                set properties of gradient stop 2 of This_Gradient to ¬
                    {midpoint:50, ramp point:100.0, color:{cyan:10, magenta:100, yellow:100, black:0}}
            end if
            if exists path item 1 then
                set fill color of every path item to {gradient:gradient "My Gradient"}
            end if
        end tell
    end tell

    I think I the gradient angle property is broken, try rotating the object setting all the "change" properties to false, except changeFillGradients.
    rotate
    (angle
    [,changePositions]
    [,changeFillPatterns]
    [,changeFillGradients]
    [,changeStrokePattern]
    [,rotateAbout])

  • How to Calculate the angle of gradient? With atan2()????

    Hi,
    my Problem is I have 2 Points and I have to calculate the angle of gradient of the line between those two points.
    I tried it like this:
    Point2D.Double p = new Point2D.Double(5.0,4.0),                               q = new Point2D.Double(2.0,2.0);          
         double angle = Math.atan2((p.y - q.y), (p.x - q.x));
         double calc=Math.toDegrees(angle);
         System.out.println("calc: "+calc);
    but if I switching the values of the two points the Result is a other but I need a Method that returns me always the angle of gradient.
    Can anyone help me?
    Thanks

    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.text.*;
    import javax.swing.*;
    public class TrigTest
        public static void main(String[] args)
            TrigPanel trigPanel = new TrigPanel();
            JFrame f = new JFrame("Click on the panel");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(trigPanel.getTopPanel(), "North");
            f.getContentPane().add(trigPanel);
            f.getContentPane().add(trigPanel.getBottomPanel(), "South");
            f.setSize(400,300);
            f.setLocation(400,300);
            f.setVisible(true);
    class TrigPanel extends JPanel
        Point originP, endP;
        double degrees;
        JLabel
            slopeLabel,       // slope = rise/run
            angleLabel,       // anti-clockwise angle from abcissa (3 o'clock)
            relativeLabel;    // angle relative to horizontal
        NumberFormat nf;
        public TrigPanel()
            originP = new Point();
            endP = new Point();
            nf = NumberFormat.getInstance();
            nf.setMaximumFractionDigits(1);
            setBackground(Color.white);
            addMouseListener(new PointSelector());
        public void paintComponent(Graphics g)
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            int width = getWidth();
            int height = getHeight();
            int dia = Math.min(width, height)*3/5;
            originP.x = width/2;
            originP.y = height/2;
            // abcissa
            g2.draw(new Line2D.Double(originP.x, originP.y, width*4/5, originP.y));
            // line from origin to selected point
            g2.draw(new Line2D.Double(originP, endP));
            // angle arc from abcissa to selected line
            Ellipse2D e = new Ellipse2D.Double(originP.x - dia/2,
                                               originP.y - dia/2,
                                               dia, dia);
            g2.draw(new Arc2D.Double(e.getBounds(), 0, degrees, Arc2D.OPEN));
            // arrow head
            if(degrees > 10)
                double x = originP.x + (dia/2)*Math.cos(Math.toRadians(degrees));
                double y = originP.y - (dia/2)*Math.sin(Math.toRadians(degrees));
                //g2.fill(new Ellipse2D.Double(x - 1, y - 1, 2, 2));  // tip marker
                double x1 = x + 5*Math.cos(Math.toRadians(degrees - 60));
                double y1 = y - 5*Math.sin(Math.toRadians(degrees - 60));
                double x2 = x + 5*Math.cos(Math.toRadians(degrees - 120));
                double y2 = y - 5*Math.sin(Math.toRadians(degrees - 120));
                g2.draw(new Line2D.Double(x, y, x1, y1));
                g2.draw(new Line2D.Double(x, y, x2, y2));
            // origin
            g2.setPaint(Color.red);
            g2.fill(new Ellipse2D.Double(originP.x - 1, originP.y - 1, 2, 2));
        private class PointSelector extends MouseAdapter
            public PointSelector()
                endP = originP;
            public void mousePressed(MouseEvent e)
                endP = e.getPoint();
                computeSlope();
                computeAngles();
                repaint();
        private void computeSlope()
            double deltaY = endP.y - originP.y;
            double deltaX = originP.x - endP.x;
            double slope = deltaY / deltaX;
            slopeLabel.setText(nf.format(slope));
        private void computeAngles()
            double y = originP.y - endP.y;
            double x = endP.x - originP.x;
            // angle from abcissa
            double atan2 = Math.atan2(y, x);
            degrees = Math.toDegrees(atan2);
            if(degrees < 0)
                degrees += 360;
            angleLabel.setText(nf.format(degrees));
            // angle relative to horizontal - unsigned
            double atan = Math.atan(y/x);
            double relative = Math.abs(Math.toDegrees(atan));
            relativeLabel.setText(nf.format(relative));
        public JPanel getTopPanel()
            slopeLabel = new JLabel("");
            angleLabel = new JLabel("");
            setLabelSize(slopeLabel);
            setLabelSize(angleLabel);
            JPanel panel = new JPanel(new GridBagLayout());
            GridBagConstraints gbc = new GridBagConstraints();
            gbc.insets = new Insets(2,2,2,2);
            gbc.weightx = 1.0;
            addLabels(new JLabel("slope"), slopeLabel, panel, gbc);
            addLabels(new JLabel("angle"), angleLabel, panel, gbc);
            return panel;
        public JPanel getBottomPanel()
            relativeLabel = new JLabel("");
            setLabelSize(relativeLabel);
            JPanel panel = new JPanel(new GridBagLayout());
            GridBagConstraints gbc = new GridBagConstraints();
            gbc.insets = new Insets(2,2,2,2);
            addLabels(new JLabel("angle relative to horizontal"),
                                  relativeLabel, panel, gbc);
            return panel;
        private void setLabelSize(JLabel label)
            label.setPreferredSize(new Dimension(50, 25));
        private void addLabels(JLabel label1, JLabel label2,
                               JPanel panel, GridBagConstraints gbc)
            gbc.anchor = gbc.EAST;
            panel.add(label1, gbc);
            gbc.anchor = gbc.WEST;
            panel.add(label2, gbc);
    }

Maybe you are looking for

  • Can't get in to ITunes - please help!!!!

    Have recently downloaded iTunes 7.0 and am not able to access itunes. Error message keeps saying - ITUNES COULD NOT CONNECT TO MUSIC STORE - MAKE SURE YOUR NETWORK CONNECTION IS ACTIVE. Have tried all advice listed, uninstalling and reinstalling,pop

  • Modules with Halo Theme causes errors in other modules with Spark theme

    Hi, We have a large application which calls several modules, some old and some new. Most modules and the main App are using only MX components and were styled based on default mx theme, thus we want to compile these modules with the flag to use the o

  • Need a little help,a nd maybe some advice

    I just finished making the beginning of a character planner for an rpg I play. I got the basic features done, and went about making a quick console interface for it so I could give it out and have people test it for me. Here's the source: http://www.

  • Error code 80070308 for all windows update

    Hi, I'm unable to install any kind of update. The install finishes with the following message : Unknown error code 80070308. My system info is as follows: OS: win7 Pro 32-bit, downloaded from ms website Processor: AMD Athlon XP2400+ @ 2.66 GHz RAM: 1

  • Problems with report

    How do I setup a report that behaves exactly like this? I mean the highlight an forwarding the selected row... http://htmldb.oracle.com/pls/otn/f?p=24317:111:15257318401612456898::NO::: Is there a possibility to view the "source" of the side?