3 Replies Latest reply on Apr 17, 2012 3:33 AM by mangalarajiv

    Circle Marquee

    mangalarajiv Level 1

      Hi,

       

           I would like to draw a circle and fill the colors inside that. So Could you please help how to draw a circle marquee through scripting.

       

      thanks,

      rajiv.s

        • 1. Re: Circle Marquee
          Paul Riggott Level 6

          Here is an example...

           

           

          app.documents.add();
          var StrokePixels = 5;
          var Red = new SolidColor;
          Red.rgb.hexValue = 'ff0000';
          var Blue = new SolidColor;
          Blue.rgb.hexValue = '0000ff';
          var Width = activeDocument.width.as('px');
          var Height = activeDocument.height.as('px');
          Circle(0,0,Height,Height,0); 
          activeDocument.selection.fill(Red);
          activeDocument.selection.stroke (Blue, StrokePixels, StrokeLocation.INSIDE,ColorBlendMode.NORMAL,100);
          activeDocument.selection.deselect();
          
          function Circle(Top,Left,Bottom,Right,Feather) { 
          if(Feather == undefined) Feather = 0;
          var desc3 = new ActionDescriptor(); 
                  var ref1 = new ActionReference(); 
                  ref1.putProperty( charIDToTypeID('Chnl'), charIDToTypeID('fsel') ); 
              desc3.putReference( charIDToTypeID('null'), ref1 ); 
                  var desc4 = new ActionDescriptor(); 
                  desc4.putUnitDouble( charIDToTypeID('Top '), charIDToTypeID('#Pxl'), Top ); 
                  desc4.putUnitDouble( charIDToTypeID('Left'), charIDToTypeID('#Pxl'), Left ); 
                  desc4.putUnitDouble( charIDToTypeID('Btom'), charIDToTypeID('#Pxl'), Bottom ); 
                  desc4.putUnitDouble( charIDToTypeID('Rght'), charIDToTypeID('#Pxl'), Right ); 
              desc3.putObject( charIDToTypeID('T   '), charIDToTypeID('Elps'), desc4 ); 
              desc3.putUnitDouble( charIDToTypeID('Fthr'), charIDToTypeID('#Pxl'), Feather );
              desc3.putBoolean( charIDToTypeID('AntA'), true ); 
              executeAction( charIDToTypeID('setd'), desc3, DialogModes.NO ); 
          };  
          
          
          
          • 2. Re: Circle Marquee
            mangalarajiv Level 1

            Thanks for great help! I just load and run the script it shows illegal argument Line 23.

            • 3. Re: Circle Marquee
              mangalarajiv Level 1

              I have modified little bit in that script. It's working now. thank you so much for your help.

               

              var rulerUnits = app.preferences.rulerUnits;

              app.preferences.rulerUnits = Units.PIXELS;

               

              var docRef = documents.add(501, 501, 72, "My Document", NewDocumentMode.RGB);

               

              var StrokePixels = 5;

              var Red = new SolidColor;

              Red.rgb.hexValue = 'ff0000';

              var Blue = new SolidColor;

              Blue.rgb.hexValue = '0000ff';

              var Width = activeDocument.width.as('px');

              var Height = activeDocument.height.as('px');

              Circle(0,0,Height,Height,0);

              activeDocument.selection.fill(Red);

              activeDocument.selection.stroke (Blue, StrokePixels, StrokeLocation.INSIDE,ColorBlendMode.NORMAL,100);

              activeDocument.selection.deselect();

               

              function Circle(Top,Left,Bottom,Right,Feather) {

              if(Feather == undefined) Feather = 0;

              var desc3 = new ActionDescriptor();

                      var ref1 = new ActionReference();

                      ref1.putProperty( charIDToTypeID('Chnl'), charIDToTypeID('fsel') );

                  desc3.putReference( charIDToTypeID('null'), ref1 );

                      var desc4 = new ActionDescriptor();

                      desc4.putUnitDouble( charIDToTypeID('Top '), charIDToTypeID('#Pxl'), Top );

                      desc4.putUnitDouble( charIDToTypeID('Left'), charIDToTypeID('#Pxl'), Left );

                      desc4.putUnitDouble( charIDToTypeID('Btom'), charIDToTypeID('#Pxl'), Bottom );

                      desc4.putUnitDouble( charIDToTypeID('Rght'), charIDToTypeID('#Pxl'), Right );

                  desc3.putObject( charIDToTypeID('T   '), charIDToTypeID('Elps'), desc4 );

                  desc3.putUnitDouble( charIDToTypeID('Fthr'), charIDToTypeID('#Pxl'), Feather );

                  desc3.putBoolean( charIDToTypeID('AntA'), true );

                  executeAction( charIDToTypeID('setd'), desc3, DialogModes.NO );

              };