Note that there are some explanatory texts on larger screens.

plurals
  1. POMixing two colors "naturally" in javascript
    primarykey
    data
    text
    <p><strong>The problem:</strong> I want to mix two colors in javascript, and get the result color. There are a lot of similar question on SO, however I doesn't find anything that actually works correctly. I know that mixing two different colored paints(pigments) and lights will give very different results (<a href="http://en.wikipedia.org/wiki/Color_mixing" rel="noreferrer">http://en.wikipedia.org/wiki/Color_mixing</a>). </p> <p>Here are the questions and suggested solutions I've already seen, and tried to implement:</p> <p><strong>1:</strong> <a href="https://stackoverflow.com/q/1892020/240324">Mixing two RGB color vectors to get resultant</a> <br/> So, mixing colors in RGB. I implemented it, and in some cases it works in some cases it doesn't.</p> <p><strong>Working example:</strong> Mixing <code>red</code> with <code>yellow</code> -> <code>orange</code>. Great!<br/> <a href="http://jsbin.com/afomim/1/edit" rel="noreferrer">http://jsbin.com/afomim/1/edit</a></p> <p><strong>Not working example:</strong> Mixing <code>blue</code> with <code>yellow</code> -> <code>gray</code>. Not so great! :) <a href="http://jsbin.com/afomim/5/edit" rel="noreferrer">http://jsbin.com/afomim/5/edit</a><br/> I know that in RGB mixing <code>blue</code> with <code>yellow</code> will never make <code>green</code>, and I understand why. </p> <p>We will not find the answer here, let's go forward.</p> <p><strong>2:</strong> <a href="https://stackoverflow.com/q/10139833/240324">Adding Colours (Colors) Together like Paint (Blue + Yellow = Green, etc) </a></p> <p>Let's try to work with CMYK values as suggested in this discussion. Mixing <code>cyan</code> with <code>yellow</code> gives <code>green</code>: <br /> <a href="http://jsbin.com/igaveg/1/edit" rel="noreferrer">http://jsbin.com/igaveg/1/edit</a> <br /> but mixing <code>blue</code> with <code>yellow</code> results in <code>black</code>. <br/> <a href="http://jsbin.com/igaveg/2/edit" rel="noreferrer">http://jsbin.com/igaveg/2/edit</a> -> Not working!</p> <p><strong>3:</strong> <a href="https://stackoverflow.com/q/398224/240324">How to mix colors &quot;naturally&quot; with C#?</a><br/> A very similar question. The most upvoted answer suggests to convert colors to LAB, and this solution seems promising.<br/> So I converted my colors to LAB. The conversion algo is correct, I tested it!</p> <p><a href="http://jsbin.com/oxefox/1/edit" rel="noreferrer">http://jsbin.com/oxefox/1/edit</a></p> <p>Now I have the two colors in LAB, but how to mix them?</p> <p><strong>NOTE</strong> I know that probably I will not find an algo that mixes <code>blue</code> with <code>yellow</code> and will give the perfect <code>green</code>, but I hope I can generate something similar to green :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    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