masakudamatsu / color-picker-nova

Pick a color by the contrast ratio to pure black and how much grey is mixed with pure hue
MIT License
0 stars 0 forks source link

Render the color triangle for a given hue #1

Open masakudamatsu opened 3 years ago

masakudamatsu commented 3 years ago

Each color is located at

Clicking a particular point of the triangle shows the RGB color code and copy it onto the user's clipboard

masakudamatsu commented 3 years ago

Initial implementation plan

masakudamatsu commented 3 years ago

Next up:

masakudamatsu commented 3 years ago

Initial implementation plan #2

Create ColorTriangel component as <svg>

e.g. If the pure hue is red (rgb(255, 0, 0))

const red = (255x + y(100-x))/100;
const green = y(100-x)/100
const blue = y(100-x)/100
masakudamatsu commented 3 years ago

Change in the implementation

Calculate luminance as percentage in the ColorTriangle component and pass it as luminance props to Color component.

masakudamatsu commented 3 years ago

Change in the implementation #2

We do not nest the loop

Instead, we create Colors component, which loops over the y value for a given x value (as prop)

Then we create ColorTriangle component which loops over the x value to render Colors components

masakudamatsu commented 3 years ago

We do not have a component test for ColorTriangle

masakudamatsu commented 3 years ago

Hovering over a color pixel now shows its RGB code.

Next: Clicking it copies the RGB code into clipboard.

masakudamatsu commented 3 years ago

HTML5 Canvas appears to be the standard method of creating a color picker.

We will explore this possibility in #4