Jump to content

help, PHP GD mix colors yellow+blue = green instead of grey?


xekon

Recommended Posts

I am trying to overlay some colors, and in some cases images with color and transparency.http://xekon.byethost7.com/ (if the image breaks, try refreshing the page) if I take a solid yellow picture, and overlay a 50% transparent blue, I get grey, or close to it depending on the levels of transparency. and it makes sense because yellow: rgba(255,255,0,1)blue: rgba(0,0,255,0.4) together rgb values all balance out to equal, and when all three are equal the color is grey. but in art, if you mix yellow & blue paint you get green paint, anyone know if this is possible using php gd?http://www.enchanted...lormixing.shtml here is a good example, click the yellow and the blue, and you get a green box: http://painting.about.com/library/blpaint/blcolormixingpalette1.htm I am thinking it might be possible but that I would need to write a custom function that makes use of the php gd functions, reading over the various functions I do not see anything that would work. http://www.php.net/m...n/ref.image.php

Edited by xekon
Link to comment
Share on other sites

Color mixing with light and with pigments works completely differently. We deal with light, our monitors use light to show color. With pigment, white is the absence of color. With light, white is all colors (0xFFFFFF). With pigment, if you mix all colors you get black. With light, black is lack of any color (0x000000). The two are totally different, when you mix different colors in light you get different results then when you mix different colors with pigment like paint or ink. I haven't heard of pre-built functions to have PHP combine colors like you would see with pigment, but I bet someone has created an algorithm to do that. If you're starting with images instead of specifying the colors then the difficult part for you is check, for each pixel, which pixels are getting combined and what their colors are.

  • Like 1
Link to comment
Share on other sites

ah, that explains a bit. and should definitely help in searching for the algorithm I need. Thank you :)

Link to comment
Share on other sites

There seems to be a big flaw in the way they teach colors in school. The primary colors for paint are cyan, magenta and yellow. The primary colors for light are red, green and blue. If you want to mix two colors to get green, mix cyan and yellow. The color values in RGB for cyan are (0,255,255) and for yellow are (255,255,0). Mix them and you'll get green.

  • Like 1
Link to comment
Share on other sites

Yes, thank you both. after your comments I found a post explaining the difference I just wasnt using the right search terms: http://stackoverflow...ed-color-in-rgb quote: "It turns out that what you and I learned in grade school is really more accurately known as a subtractive color model, versus the additive color model used by RGB." I'm not going to bother trying to change or convert anything. It was just that when I seen the result of mixing yellow and blue and didn't get green I immediately thought something was wrong, but now that I know its possible to get green, you just have to mix cyan and yellow, I am not going to bother.

Edited by xekon
Link to comment
Share on other sites

Yeah, color is pretty weird. Maybe a blue object isn't actually blue, maybe it's objectively yellow. If we see an object as blue because it absorbs all colors except blue, which it reflects back to our eyes, then maybe it's actually objectively yellow since blue is the only color that it doesn't absorb. If white light hits the object, and it absorbs everything in the white light except blue, and if you subtract blue from white light and are left with yellow, then maybe if you could see the object objectively instead of subjectively then it would actually be yellow. maaaaaan

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...