4 Replies Latest reply on Aug 5, 2011 4:31 AM by JJ0330

    AppleScript - gradient ramp location?

    JJ0330

      Hi, we are looking to control gradient ramp location from AppleScript.  I think this is what it is because if go into swatch options for gradient created with below code, it has an option for Gradient Ramp where you can put in a percentage so we'd like to be able to do that somehow in AppleScript. Tried various options in the make new gradient properties because able to control name and type there but not sure how to control the gradient ramp?

       

       

        set ColorA to make color with properties {model:process, color value:{50, 0, 0, 0}, name:"Color A"}
        set ColorB to make color with properties {model:process, color value:{0, 0, 0, 0}, name:"Color B"}
        set GradAtoB to make new gradient with properties {name:"GradA-B", type:linear}  --Is there any option here?
        set stop color of first gradient stop of GradAtoB to ColorA
        set stop color of last gradient stop of GradAtoB to ColorB
        set fill color of first rectangle to GradAtoB

       

      Thanks,

      Joe

        • 1. Re: AppleScript - gradient ramp location?
          JJ0330 Level 1

          I think I can get it to work as below but looks like setting the length is by inches but would like to do by percent if possible?

           

            set ColorA to make color with properties {model:process, color value:{50, 0, 0, 0}, name:"Color A"}
            set ColorB to make color with properties {model:process, color value:{50, 0, 0, 0}, name:"Color B"}
            set GradAtoB to make new gradient with properties {name:"GradA-B", type:linear}
            set stop color of first gradient stop of GradAtoB to ColorA
            set stop color of last gradient stop of GradAtoB to ColorB
            set gradient fill angle of rectangle 1 to 90
            set fill color of the first rectangle to GradAtoB
            set gradient fill length of first rectangle to 1   --Can we do percentage?

           

           

          Thanks.

          • 2. Re: AppleScript - gradient ramp location?
            Larry G. Schneider Adobe Community Professional & MVP

            That may well be a 0 to 1 as 0% to 100% so the middle would be 0.5. You may have to try it to confirm.

            1 person found this helpful
            • 3. Re: AppleScript - gradient ramp location?
              Muppet Mark Level 5

              You change ramp points and stop locations in your gradient… Midpoint is in range 13-87. Gradient length and start point are for using like dragging the gradient tool…

               

              tell application "Adobe InDesign CS5"

                   tell document 1

               

                        set ColorA to make color with properties ¬

                        {model:process, color value:{50, 50, 10, 0}, name:"Color A"}

                        set ColorB to make color with properties ¬

                        {model:process, color value:{0, 50, 100, 0}, name:"Color B"}

               

                        set GradAtoB to make new gradient ¬

                        with properties {name:"Gradient A-B"}

               

                        set stop color of first gradient stop of GradAtoB to ColorA

                        set location of first gradient stop of GradAtoB to 10

               

                        set stop color of last gradient stop of GradAtoB to ColorB

                        set location of last gradient stop of GradAtoB to 80

               

                        set midpoint of last gradient stop of GradAtoB to 70

               

                        set fill color of the first rectangle to GradAtoB

               

                        set gradient fill angle of the first rectangle to 45

               

                   end tell

              end tell

              • 4. Re: AppleScript - gradient ramp location?
                JJ0330 Level 1

                Great, that will work.  Thanks.