5 Replies Latest reply on Jun 2, 2014 6:27 AM by c.pfaffenbichler

    Scripting paint bucket with specified color


      Hi, I was trying to figure out how I can fill a layer with a specified color. I realize there are ways to do with with the fill() tool, but I'd rather try to implement this throughout the paint bucket tool (modeling off of what is outputted from script listener).


      Not sure if one way is faster than the other, but in my case, the layer is already blank so it won't matter what coordinates I specify in the script...


      My issue with what I see in the script listeners (the second code block), is that it automatically picks the foreground color to fill the layer. But how can I determine my own color with something like in the following code block:


      var fillColor = new SolidColor();
              fillColor.rgb.blue = 128;
              fillColor.rgb.green = 200;
              fillColor.rgb.red = 74;


      And here is what was generated by the script listener upon using the paint bucket tool to fill an empty layer:


      var idFl = charIDToTypeID( "Fl  " );
          var desc251 = new ActionDescriptor();
          var idFrom = charIDToTypeID( "From" );
              var desc252 = new ActionDescriptor();
              var idHrzn = charIDToTypeID( "Hrzn" );
              var idPxl = charIDToTypeID( "#Pxl" );
              desc252.putUnitDouble( idHrzn, idPxl, 367.000000 );
              var idVrtc = charIDToTypeID( "Vrtc" );
              var idPxl = charIDToTypeID( "#Pxl" );
              desc252.putUnitDouble( idVrtc, idPxl, 371.000000 );
          var idPnt = charIDToTypeID( "Pnt " );
          desc251.putObject( idFrom, idPnt, desc252 );
          var idTlrn = charIDToTypeID( "Tlrn" );
          desc251.putInteger( idTlrn, 32 );
          var idAntA = charIDToTypeID( "AntA" );
          desc251.putBoolean( idAntA, true );
          var idUsng = charIDToTypeID( "Usng" );
          var idFlCn = charIDToTypeID( "FlCn" );
          var idFrgC = charIDToTypeID( "FrgC" );
          desc251.putEnumerated( idUsng, idFlCn, idFrgC );
      executeAction( idFl, desc251, DialogModes.NO );