Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to show Color Picker value (draw zone)

Participant ,
Dec 12, 2013 Dec 12, 2013

Hello to all

How to make a selection of Color Picker direct the user can see the selected color? In my example - the color selected by Color Picker should paint the square. Any variants ? Preferably with DOM.

var wColor= new Window('dialog', ' ');

    wColor.orientation = "column";

    wColor.alignment="top";

    wColor.spacing=0;

        wgr1=wColor.add('group');

        wgr1.orientation = 'row';

        wgr1.alignment='top';

            btnRGB1= wgr1.add('button',undefined,'RGB');

            btnRGB1.preferredSize = [50,20];

            p1 =  wgr1.add("panel", undefined, "", {borderStyle:"silver"});

            p1.preferredSize = [22,22];

        wgr2=wColor.add('group');

        wgr2.orientation = 'row';

        wgr2.alignment='top';

            btnRGB2= wgr2.add('button',undefined,'RGB');

            btnRGB2.preferredSize = [50,20];

            p2 =  wgr2.add("panel", undefined, "", {borderStyle:"silver"});

            p2.preferredSize = [22,22];

    btnRGB1.onClick = function(){//-------------------------------------------------------

        app.showColorPicker();

    }

    btnRGB2.onClick = function(){//-------------------------------------------------------

        app.showColorPicker();

    }

wColor.show()

TOPICS
Actions and scripting
1.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Dec 12, 2013 Dec 12, 2013

Try this:

#target photoshop

var color1 = new SolidColor()

var color2 = new SolidColor()

var wColor= new Window('dialog', ' ');

    wColor.orientation = "column";

    wColor.alignment="top";

    wColor.spacing=0;

        wgr1=wColor.add('group');

        wgr1.orientation = 'row';

        wgr1.alignment='top';

            btnRGB1= wgr1.add('button',undefined,'RGB');

            btnRGB1.preferredSize = [50,20];

            p1 =  wgr1.add("panel", undefined, "", {borderStyle:"silver"});

            p1.preferredSi

...
Translate
Adobe
Community Expert ,
Dec 12, 2013 Dec 12, 2013

Try this:

#target photoshop

var color1 = new SolidColor()

var color2 = new SolidColor()

var wColor= new Window('dialog', ' ');

    wColor.orientation = "column";

    wColor.alignment="top";

    wColor.spacing=0;

        wgr1=wColor.add('group');

        wgr1.orientation = 'row';

        wgr1.alignment='top';

            btnRGB1= wgr1.add('button',undefined,'RGB');

            btnRGB1.preferredSize = [50,20];

            p1 =  wgr1.add("panel", undefined, "", {borderStyle:"silver"});

            p1.preferredSize = [22,22];

        wgr2=wColor.add('group');

        wgr2.orientation = 'row';

        wgr2.alignment='top';

            btnRGB2= wgr2.add('button',undefined,'RGB');

            btnRGB2.preferredSize = [50,20];

            p2 =  wgr2.add("panel", undefined, "", {borderStyle:"silver"});

            p2.preferredSize = [22,22];

    btnRGB1.onClick = function(){//-------------------------------------------------------

        app.showColorPicker();

        color1.rgb.red = app.foregroundColor.rgb.red       

        color1.rgb.green= app.foregroundColor.rgb.green       

        color1.rgb.blue = app.foregroundColor.rgb.blue       

        g = p1.graphics;

        var myBrush = g.newBrush(g.BrushType.SOLID_COLOR, [color1.rgb.red/255,color1.rgb.green/255,color1.rgb.blue/255, 1]);

        g.backgroundColor = myBrush;

       

        try{app.foregroundColor = color1}

        catch(e){}

        try{app.backgroundColor = color2}

        catch(e){}

           

    }

    btnRGB2.onClick = function(){//-------------------------------------------------------

        app.showColorPicker();

        color2.rgb.red = app.foregroundColor.rgb.red       

        color2.rgb.green= app.foregroundColor.rgb.green       

        color2.rgb.blue = app.foregroundColor.rgb.blue          

        g = p2.graphics;

        var myBrush = g.newBrush(g.BrushType.SOLID_COLOR, [color2.rgb.red/255,color2.rgb.green/255,color2.rgb.blue/255, 1]);

        g.backgroundColor = myBrush;

       

        try{app.foregroundColor = color1}

        catch(e){}

        try{app.backgroundColor = color2}

        catch(e){}

    }

wColor.show()

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Dec 13, 2013 Dec 13, 2013

Hi,

can I ask you where does the BorderStyle: 'silver' come from?

Davide

www.davidebarranca.com

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Dec 13, 2013 Dec 13, 2013

can I ask you where does the BorderStyle: 'silver' come from?

I don't where is comes from it has the same effect as the default borderStyle:"etched". The panel has the same appearence if you omit the borderStyle property. At least in Photoshop.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Dec 13, 2013 Dec 13, 2013
LATEST

Snap! Silver sounded promising

Looks like the default etched to me too on Mac - I hoped to have missed an interesting property.

Davide

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines