Path: utzoo!attcan!uunet!cs.dal.ca!ug.cs.dal.ca!legrady From: legrady@ug.cs.dal.ca (Tom Legrady) Newsgroups: comp.graphics Subject: Re: RGB color mixing/averaging Keywords: RGB, super-sampling, transparency Message-ID: <1990Mar15.145623.2096@ug.cs.dal.ca> Date: 15 Mar 90 14:56:23 GMT References: <173@yak.COM> Reply-To: legrady@ug.cs.dal.ca.UUCP (Tom Legrady) Organization: Math, Stats & CS, Dalhousie University, Halifax, NS, Canada Lines: 31 In article <173@yak.COM> tpd6908@yak.COM (Tom Dickens) writes: >I am looking for a simple routine that will take 2 rgb values, a ratio >for mixing them (ie. 0.5), and will return the resulting rgb value. >This is desired for determining a pixel color after super-sampling, or when >combining colors while working with transparent surfaces. > >The problem I have is I expect the resulting rgb value to follow >'real world' results. (ie. case1: red+blue=purple, case2: blue+yellow=green) The problem is not in the algorithmn, but in you selection of 'primary' colours. Blue paint mixed with yellow paint looks green. That's subtractive mixing. You started with white light and reduced level of non-yellow colours. Then from that you reduced the non-blue colours. Since green is between yellow and green, it passed through both filters. When you mix RGB values, as when you point several stage lights at the same location, you get additive mixing. You start with Black, add some Blue, then add some yellow (which is a mixture of red and green) ... Voila ... _WHITE_!!! It took me a while to pound the additive rules into my head: PRIMARIES Red Green Blue Red + Green = Yellow Green + Blue = Cyan (pale blue) Red + Green = Magenta (deep purple) The sequence of combinations brightes to darkest is White Yellow Cyan Green Magenta Red Blue Black.