Create gradient for color selection with HTML5 canvas (all possible RGB colors)

前端 未结 3 702
我寻月下人不归
我寻月下人不归 2021-01-17 00:39

Is it possible to greate a linear gradient which contains all possible RGB colors (only red, green, blue - no alpha values) for a linear color picker.

So far I\'ve t

3条回答
  •  醉话见心
    2021-01-17 01:31

    +1 Philipp is spot on. RGB colors are not well represented in 2d space because rgb has 3 components that all must be represented.

    The closest you can get to geometrically representing all rgb combinations is a cube (makes sense since a cube has 3 axes and rgb has 3 values).

    Here's an illustration from Wikipedia: http://en.wikipedia.org/wiki/RGB_color_space

    enter image description here

    You could use this as a starting place and use a slider to show each color "layer" from front to back.

提交回复
热议问题