colorPicker& set mask

image
צילום מסך 2025-03-03 133246

Hi Dan,
I built a color picker, and I set a mask for it, and it still lets you choose a color even outside the mask.
I checked and even if I build an object on the color picker, even above the object it still lets you choose a color.
Is there a way to limit it? I want it so that outside the mask there will be no option to choose a color.

I'm attaching the code both with a mask and without a mask and with an object above. and pictures.

Thanks.

const cp = new ColorPicker()
                .show() 
                .change(() => {
                    zog(cp.selectedColor); 
                    zog(cp.selectedAlpha); 
                });

            let mask = new Rectangle(100, 100, "#FFF65B").center().mov(0,-50).top().alp(0);

            cp.setMask(mask)



or:


const cp = new ColorPicker()
                .show() 
                .change(() => {
                    zog(cp.selectedColor); 
                    zog(cp.selectedAlpha); 
                });

            let mask = new Rectangle(100, 100, "#FFF65B").center().mov(0,-50).top()

I guess there are some rollover settings causing the problems. It is pretty easy to make a gradient and then just get the color under the mouse - so make your own. If you have any problems with that, let us know and we can do a sample.

1 Like

Thanks, I tried to do as you said – I created a rectangle with GradientColor, and I tried to insert it into Bitmap and use addBitmapData, but I got an error saying it's not a function. I also tried taking your example with Bitmap using addBitmapData, and it also says it's not a function. I then tried using your example with createjs.BitmapData, but it says it's not a constructor. I would appreciate your help.

You need to use createjs 1.5.0. Importing ZIM 017 will do that. Earlier versions will not. Make sure to clear your cache too.

You can get the color under the mouse without the BitmapData class - there is the getColorAt(x,y) method. So that is what you want - not color() as that applies a color to the bitmap (if you have a Bitmap with BitmapData).

thanks

1 Like