First-class colors (Part 3)

Continuing the discussion from First-class colors (Part 2) - #109 by bh.

Previous discussions:

@sathvikrias: You added four blocks. One of them was redundant:
color improvmnts script pic
is already an option in SET PEN:
fix colors script pic
(The first pulldown now distinguishes "color" from "color number.")

Another should have been redundant, and is in my revised library below; this:


is the same as either of these:


(Any vector option can include a fourth transparency value. If it's an RGB vector, the opacity is 0-255, but for other vectors transparency is 0-100.)

Which brings us to your last two blocks:
color improvmnts script pic color improvmnts script pic
I'm hoping that those won't be needed, because SET PEN and COLOR FROM "do the right thing" about letting you specify colors in the natural scale for whichever option you choose.

@cymplecy: Thanks for fixing the code. I knew that some options don't have associated pulldown menus, but somehow didn't test trying to pull one down anyway. :~)

I swear CURRENT PEN COLOR worked last night! Must have been gremlins.

Here's the revised library: colors.xml (234.9 KB)

alright imma find more bugs with the library.

are these for emergencies

Okay, by popular demand, a MIX block. colors.xml (240.9 KB)

image

but get this

untitled script pic (1)

but other reporter is fine

untitled script pic (2)

Ah, thank you. I have to change that option to be called "color number."

the mix block is broken,

that is not mixing by paint.
also can you add a percentage input in that block?

the option RGB vector

block should be called RGB/RGBA vector

Yup.

The mix block does ideal subtractive mixing. Turns out real paint involves subtractive, additive, and additive averaged mixing. :~( I'll work on that asap.

About percentages, right now I'm using each color's transparency as a weighting factor. I'm hoping that will make y'all happy so I don't have to hair up the variadic color inputs.

colors.xml (242.0 KB)

maybe a separate paint mixing block with a percentage?

I'm just reading the chapter on mixing physical paints... I'll work on it again when I finish!

what are you reading?

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!