Skip to main content
Known Participant
August 24, 2016
Question

i want to make fill color based on foreground color

  • August 24, 2016
  • 1 reply
  • 393 views

i want to make fill color based on foreground color and thanks alot

makeSolidFill (255,255,255)

removeMask () 

 

function makeSolidFill(redC,greenC,blueC){ 

  // ======================================================= 

    var idMk = charIDToTypeID( "Mk  " ); 

        var desc15 = new ActionDescriptor(); 

        var idnull = charIDToTypeID( "null" ); 

            var ref4 = new ActionReference(); 

            var idcontentLayer = stringIDToTypeID( "contentLayer" ); 

            ref4.putClass( idcontentLayer ); 

        desc15.putReference( idnull, ref4 ); 

        var idUsng = charIDToTypeID( "Usng" ); 

            var desc16 = new ActionDescriptor(); 

            var idType = charIDToTypeID( "Type" ); 

                var desc17 = new ActionDescriptor(); 

                var idClr = charIDToTypeID( "Clr " ); 

                    var desc18 = new ActionDescriptor(); 

                    var idRd = charIDToTypeID( "Rd  " ); 

                    desc18.putDouble( idRd, redC);//Red variable 

                    var idGrn = charIDToTypeID( "Grn " ); 

                    desc18.putDouble( idGrn, greenC);//green variable 

                    var idBl = charIDToTypeID( "Bl  " ); 

                    desc18.putDouble( idBl, blueC );//blue variable 

                var idRGBC = charIDToTypeID( "RGBC" ); 

                desc17.putObject( idClr, idRGBC, desc18 ); 

            var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" ); 

            desc16.putObject( idType, idsolidColorLayer, desc17 ); 

        var idcontentLayer = stringIDToTypeID( "contentLayer" ); 

        desc15.putObject( idUsng, idcontentLayer, desc16 ); 

    executeAction( idMk, desc15, DialogModes.NO );   

    } 

 

function removeMask(){ 

    var idDlt = charIDToTypeID( "Dlt " ); 

        var desc21 = new ActionDescriptor(); 

        var idnull = charIDToTypeID( "null" ); 

            var ref5 = new ActionReference(); 

            var idChnl = charIDToTypeID( "Chnl" ); 

            var idChnl = charIDToTypeID( "Chnl" ); 

            var idMsk = charIDToTypeID( "Msk " ); 

            ref5.putEnumerated( idChnl, idChnl, idMsk ); 

        desc21.putReference( idnull, ref5 ); 

    executeAction( idDlt, desc21, DialogModes.NO ); 

    } 

This topic has been closed for replies.

1 reply

pixxxelschubser
Community Expert
Community Expert
August 24, 2016

Hi mohameds30135418​,

replace your line:

makeSolidFill (255,255,255);

with these lines:

var rd = app.foregroundColor.rgb.red;

var bl = app.foregroundColor.rgb.blue;

var gr = app.foregroundColor.rgb.green;

makeSolidFill (rd, bl, gr);

Have fun

Known Participant
August 24, 2016

yo are great man ..it`s worked .. i want to save color table and thanks alot