First-class colors (Part 3)

The Dimensions of Color by David Briggs.

ok, I thought you were reading something on the internet

It is on the Internet! That's why the title is clickable.

oh doh.

Okay here's the current status: colors.xml (253.5 KB)

So here's the thing. For additive mixing, or for the kind of subtractive mixing you get by putting transparent colored filters over white light sources (as in theaters), a color is a color. If you know its RGB (or any of a bunch of equivalent measures), that's all you need to know to mix colors.

But paint is a whole different story. To get even an approximate result color, you need to know the reflectance spectrum of the specific paints. There are programs you can buy that include spectra of every color of every brand of artist's paint. What does spectrum mean? Well, you know that adding red and green light on your computer screen causes your eyes to report yellow. But when you see yellow in the rainbow, it's not made by adding red and green; it's its own wavelength of light. So you could imagine one paint that reflects red and green, and a different paint that reflects yellow, and they'd both look yellow separately, but when mixed with other colors they'd behave very differently. (Real paints, by the way, don't just reflect single wavelengths; they reflect wide bands of wavelengths.)

So mixing paint colors starting with just RGB values isn't merely hard; it's theoretically impossible.

Having said that, this guy, Scott Burns, has an algorithm to turn RGB colors into more or less typical, realistic reflectance spectra, and then to mix them. So I implemented it, but I'm not sure you'll be happy with the results:
orange-plain

Google Chrome001 1.41.59 AM
As you can see, the resulting color isn't quite the same as red -- it does have a bit of yellow in its spectrum. But it's not the orange you're hoping for.

There are two ways to make this more orange. One is to do sRGB gamut correction on the result:
orange-sRBG
But that makes CMY combinations washed out:
blue-plain
blue-sRBG

The other way to get a strong orange is to change the proportion in which the colors are mixed:


(By the way, this is how I propose to let you specify weights without hairing up the MIX block itself. Colors without explicit weights are at 1.)

But actually, I think probably the behavior of the MIX block does reflect how paints mix, which is why painters use CMYK palettes rather than RGB. I think this may be finished, unless y'all find more problems.

Here's the library documentation (the part in the main body of the manual; I'm still working on Appendix A). color-library.pdf (1.9 MB)

5 posts were split to a new topic: Uploading files to forum posts

Thank you for posting the PDF! It really helps!

What are those?

Variadic basically means multiple. This is a variadic color input:
image
Also welcome to the forums!

thank you!

(I like Taco Bell a lot lol :stuck_out_tongue: )

We should have this block.

[scratchblocks] (color #[ffffff] :: pen) [/scratchblocks]

how do you set the color of [scratchblocks]?

@sathvikrias answer this.

@helicoptur please do not start an edit war

@bh why did you delete the home page?

I was deleting an edit war.

But I think you're confused about the status of this work. There will shortly be an official Colors and Crayons library that supports first class colors. Several people in this discussion thread have contributed ideas to it, for which thank you, but this isn't going to be a collaborative project; it's going to be an official Snap! library, pretty much written by me.

The thread started out as a feature request; look at its category! And it was answered with a "yes"! We're implementing this feature, although it's in a library (at least so far). Ideas for improvement are welcome; that's why I've been posting partial implementations.

will it be programmed in js or snap! ?

It's almost entirely in Snap!, apart from a couple of one-liners to extract the RGB or HSV values from the pen color. Read the code! Here it is: color.xml (253.5 KB)

Okay, here is the final-for-now library: color.xml (254.0 KB)
and here's Appendix A of the manual, explaining it: color-appendix.pdf (4.0 MB)

Bug reports still welcome. Feature suggestions will probably be deferred until the next time I have nothing else to do; other things require my attention now. (Besides cleaning up after your flame wars, I mean.)