PHP allocate color without image resource

16711680 (decimal) is 0x00FF0000 (hexadecimal) 00 – Alpha value (0 dec) FF – Red (255 dec) 00 – Green (0 dec) 00 – Blue (0 dec) See http://www.php.net/manual/en/function.imagecolorallocatealpha.php to set the alpha byte Edit: Also, to answer your first question — yes, you can create a color without an image resource (and, consequently without a … Read more

Javascript Regular Expression for rgb values

Here is some example code that should do approximately what you need or set you in the right direction: var color=”rgb(255, 15, 120)”; var matchColors = /rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)/; var match = matchColors.exec(color); if (match !== null) { document.write(‘Red: ‘ + match[1] + ‘ Green: ‘ + match[2] + ‘ Blue: ‘ + match[3]); } … Read more

How to convert RGB -> YUV -> RGB (both ways)

Yes, invertible transformations exist. equasys GmbH posted invertible transformations from RGB to YUV, YCbCr, and YPbPr, along with explanations of which situation each is appropriate for, what this clamping is really about, and links to references. (Like a good SO answer.) For my own application (jpg images, not analog voltages) YCbCr was appropriate, so I … Read more

Generating gradients programmatically?

you want an interpolation between the first and the second colour. Interpolating colours is easy by calculating the same interpolation for each of its components (R, G, B). There are many ways to interpolate. The easiest is to use linear interpolation: just take percentage p of the first colour and percentage 1 – p of … Read more

From RGB to HSV in OpenGL GLSL

I am the author of the second implementation. It has always behaved correctly for me, but you wrote 2.9 / 6.9 instead of 2.0 / 6.0. Since you target GLSL, you should use conversion routines that are written with the GPU in mind: // All components are in the range [0…1], including hue. vec3 rgb2hsv(vec3 … Read more

RGB to HSL conversion

I’ve been reading several wiki pages and checking different calculations, and creating visualizations of RGB cube projection onto a hexagon. And I’d like to post my understanding of this conversion. Since I find this conversion (representations of color models using geometric shapes) interesting, I’ll try to be as thorough as I can be. First, let’s … Read more