Name that color

http://chir.ag/projects/ntc/

There is a really simple java script that queiries a list of hex and color names, but being both java and c# ignorant, I can’t work out how to make a plugin out of it, can anyone help?

http://chir.ag/projects/ntc/ntc.js

Many thanks!

How’s this? ColourNameHack.vl (102.7 KB)

Ah cool, good start! DIdn’t think about using VL tbh, java and c# being so close thought it would be a quick hack for a coder. I’ll see if I can find the closest color too, thanks so much!
Not come across the cache region yet either…

But then I try and get values from a hex string in VL, and am completely lost again!

that one is weirdly called FromHTML but will be renamed to FromHex soon.

we have FromHex, which includes alpha. FromHTML doesn’t expect alpha as it is common in the web. but we could of course merge the two nodes into one and select one of the code paths depending on the length of the input string.

as answered in the vvvv chat, its basically about finding the closest color in a given list. VL has a quite nice color distance node which follows the implementation from this site:
https://www.compuphase.com/cmetric.htm

the patch then becomes as simple as:
image

with finding the nearest neighbour color like this:
image

the custom nearest neighbour color node wouldn’t be necessary if we had kept our pin names consistent. because VL already has a NearestNeighbour node that can work for colors too. will fix for upcoming alpha.

NameThatColor.zip (25.6 KB)

1 Like

That certainly solves it! The if region look a little bit magic, but I think I get it, have to try and remember it too!

You can think of it as two switches in this case in vvvv terminology.
No actual code is being executed inside the If-Region, but for FALSE the defaults will be used (top inputs getting passed down without altering the values), for TRUE on the other hand they will be set to what’s connected to the outputs of the If-Region, so these values will be used instead.

another example, either way works:
image

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.