Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Paint works by absorption. You start with white light (255,255,255) and multiply it by the absorption factors.</p> <p>Blue paint absorbs all red and green light that hits it.</p> <p>Yellow paint absorbs all blue light that hits it.</p> <p>In a perfect world, that means that combining yellow and blue paint would result in black paint, or at best a muddy gray. In practice the "blue" paint has a bias towards green, so you get a muddy green. I've never seen an example of mixing yellow and blue that produces a satisfactory green. Wikipedia goes into some of the complexities of this process: <a href="http://en.wikipedia.org/wiki/Primary_color#Subtractive_primaries" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Primary_color#Subtractive_primaries</a></p> <p>I think what you are really asking is how to interpolate colors along a color wheel. This should be independent of whether the colors are absorptive as in paint, or emissive as in RGB displays.</p> <p><strong>Edit:</strong> By working in the HSL color space you can get the kind of results you're looking for. Here's some code in Python that implements the algorithm; averaging hues is tricky, and is based on a previous answer of mine <a href="https://stackoverflow.com/questions/5343629/averaging-angles">for averaging angles</a>.</p> <pre><code>from colorsys import rgb_to_hls,hls_to_rgb from math import sin,cos,atan2,pi def average_colors(rgb1, rgb2): h1, l1, s1 = rgb_to_hls(rgb1[0]/255., rgb1[1]/255., rgb1[2]/255.) h2, l2, s2 = rgb_to_hls(rgb2[0]/255., rgb2[1]/255., rgb2[2]/255.) s = 0.5 * (s1 + s2) l = 0.5 * (l1 + l2) x = cos(2*pi*h1) + cos(2*pi*h2) y = sin(2*pi*h1) + sin(2*pi*h2) if x != 0.0 or y != 0.0: h = atan2(y, x) / (2*pi) else: h = 0.0 s = 0.0 r, g, b = hls_to_rgb(h, l, s) return (int(r*255.), int(g*255.), int(b*255.)) &gt;&gt;&gt; average_colors((255,255,0),(0,0,255)) (0, 255, 111) &gt;&gt;&gt; average_colors((255,255,0),(0,255,255)) (0, 255, 0) </code></pre> <p>Note that this answer does <strong>not</strong> emulate paint mixing, for the reasons stated above. Rather it gives an intuitive mixing of colors that is not grounded in any physical world reality.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload