How would you go about making a range of RGB colours evenly spaced over the spectral colour range? So as to look like a real rainbow.
相关问题
- DBGrid - How to set an individual background color
- How to display an image represented by three matri
- How to delete a certain part of an Image?
- Name for a method that has only side effects
- draw polylines with different colors on v2 maps
相关文章
- Emacs/xterm color annoyance on Linux
- Should client-server code be written in one “proje
- Algorithm for maximizing coverage of rectangular a
- matplotlib bwr-colormap, always centered on zero
- Is there an existing solution for these particular
- MeshLab: How to import XYZRGB file
- What is Scope Creep? [closed]
- How to add RGB values into setColor() in Java?
This class will do it with PHP, pass the constructor the number of colours you want in your rainbow and the $sequence property will contain an array of rrggbb hex codes.
To test e.g.:
I only claim credit for packaging this up into a class, the original function was found in this post: PHP HSV to RGB formula comprehension
I can draw a rainbow programmatically with JavaScript and HTML5.
I make a gradient from rgb(255,0,0) -> rgb(255,255,0) -> rgb(0,255,0) -> rgb(0,255,255) -> rgb(0,0,255) -> rgb(255,0,255).
I calculate the hex colour values along the gradient using my RainbowVis-JS library (which just chains gradients together). I draw the arc shape with HTML5 Canvas, looping through the colours.
I know it is rather old question, but here is my simple and easy to understand solution, that should be easy to use in most programming languages. Replace steps and whichStep with Your own values.
Between each colour make linear interpolation.
Use HSL instead: fix the brightness and saturation and vary the hue from 0 to 360, then convert to RGB.
HSL describes colors as they are perceived by people. RGB describes them as they are used by machines. So you can't really do anything visually pleasing directly using RGB.
You can use the HSV color space and walk across the Hue dimension.