Get cx and cy of canvas

335 Views Asked by At

I am using this color wheel, and I want to change the color of the color wheel programmatically. So if I have a color value (rgb, hsv etc.) I want to change the color wheel to that specific color?

For example, if I have hsv(150, 100, 1), I want the color wheel to change to that.

I already asked the question, but both people that answered, aren't answering the comments, and I don't know how to implement what they wrote. We'll use this answer So he said to use the following code:

var h = 150;
var s = 100;
currentX = cx - s * radius * Math.cos(PI2 * h);
currentY = cy - s * radius * Math.sin(PI2 * h);

Where cx, cy is the center of the colour wheel.

The question is, how can I define cx and cy? Or if it's already defined in the code, which variable is it?

0

There are 0 best solutions below