Open masakudamatsu opened 3 years ago
Initial implementation plan
fill
property in the style
attribute)x
and y
attributes)Next up:
Color.js
and Color.test.js
Initial implementation plan #2
Create ColorTriangel
component as <svg>
viewBox = "0 0 100 100"
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
red
/green
/blue
values are the same as the previous step in the inner loop, and if so, returnColor
component with rgb values, x, and the luminance derived from rgb values.Change in the implementation
Calculate luminance as percentage in the ColorTriangle
component and pass it as luminance
props to Color
component.
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)
Color
components with <g>
elementThen we create ColorTriangle
component which loops over the x value to render Colors
components
We do not have a component test for ColorTriangle
Hovering over a color pixel now shows its RGB code.
Next: Clicking it copies the RGB code into clipboard.
HTML5 Canvas appears to be the standard method of creating a color picker.
We will explore this possibility in #4
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