Page 2 of 2

Re: Extract color code

Posted: Thu Feb 17, 2022 7:00 pm
by FourthWorld
IIRC someone here or on the mailing list posted a CMYK conversion function within the last few years.

Re: Extract color code

Posted: Thu Feb 17, 2022 7:27 pm
by jacque
I've noticed that if I set the color from the hex pane of the color picker then that's what I get back when querying for the color. Not sure if that's useful in this case.

Re: Extract color code

Posted: Thu Feb 17, 2022 7:28 pm
by dunbarx
This shows at least one simple and direct conversion:
https://www.rapidtables.com/convert/col ... o-rgb.html
Though I have read that because the two worlds these protocols live in, print, which has four elements (CYMK) and is subtractive, and screen, which has three elements (RGB) and is additive, the conversion is not so simple.

Craig

Re: Extract color code

Posted: Thu Feb 17, 2022 8:58 pm
by bn
Here is a stack that has color type conversions from Monte Goulding. I made small corrections to it and post it here.
I talked about this stack with Monte way back on a conference in Edinburgh and he was fine with the corrections to the library and did not mind it being in the public domain. It would be nice to give him credit when using it in your project.

Kind regards
Bernd

Re: Extract color code

Posted: Sat Feb 19, 2022 7:02 pm
by richmond62
Here's a fairly goofy question:

What does max mean in this context?

K = 1-max(R', G', B')

"Its the short form of representing, a function that returns maximum among a set of given numbers."

https://math.stackexchange.com/question ... s-max-mean
-
SShot 2022-02-19 at 20.04.26.png
SShot 2022-02-19 at 20.04.26.png (5.23 KiB) Viewed 7516 times
-
Ah: nothing quite like the "soggy toast" feeling of answering one's own questions. 8)

Re: Extract color code

Posted: Sat Feb 19, 2022 7:40 pm
by richmond62
SShot 2022-02-19 at 20.37.34.png
-
Convert RGB 'guff' into CMYK 'guff'.

15 minutes on 2 very strong Gin-and-Tonics proving that the Maths on this page is
OFF by a factor of 100:

https://www.rapidtables.com/convert/col ... -cmyk.html

Stack removed as improved version posted in next post.

Re: Extract color code

Posted: Sat Feb 19, 2022 8:34 pm
by richmond62
SShot 2022-02-19 at 21.31.05.png
-
As I have never had to do this in the last 20-odd years what on earth prompted me
to look up round in the Dictionary . . .

Re: Extract color code

Posted: Wed May 22, 2024 3:27 am
by PaulDaMacMan
A couple years late to this thread, but I just wanted to add (re-CMYK) that as mentioned they're two different color worlds, additive color vs. subtractive color, so there's no perfectly correct conversion to be had.

Usually there's some adjustment made in the process of converting to CMYK from RGB, that is there's usually a color curve applied that's (probably not) calibrated to a printing device. This is referred to as GCR (gray component replacement) or UCR (under color removal).

So there's my $0.02

Re: Extract color code

Posted: Wed May 22, 2024 10:11 am
by stam
Also late to this, but just to add that the FerrusLogic team have previously ported the javascript framework TinyColor to liveCode and made it available as opensource on GitHub under the extremely permissive MIT licence (you just need to include the licence info and use in any commercial/non-commercial way you see fit): https://github.com/Ferruslogic/TinyColor

This does a ton of colour conversions and has around 70 functions. A valuable library and contribution

While it is always fun to learn by doing, to be productive using libraries like this are a must... just posting for awareness.

Stam

Re: Extract color code

Posted: Wed May 22, 2024 8:26 pm
by PaulDaMacMan
stam wrote: Wed May 22, 2024 10:11 am While it is always fun to learn by doing, to be productive using libraries like this are a must... just posting for awareness.

Stam
Right, I knew that but your posting that link (thanks) had me looking at it again and just notice there's a nice function in there:
getSystemAppearance() to check if operating system is in dark or light mode that works on Mac,iOS, Android, and Windows.

The only problem is it doesn't do Linuxes, I'm looking into doing something like that (there's a lot of variations in Linux world to consider).

There's also none for running in a browser (Emscripten / HTML5), that's easy enough to get from web API.
As seen here, fourth button from top right side: http://openxtalk.org//WebStacks/HC3PlusPlus.html