Closed enzyme69 closed 7 years ago
@enzyme69 use separate issues to ask separate questions please. questions about snlite, please direct them to the snlite thread.
but to answer your main question, a color node is probably way over due :)
I think I just screen grab the color node from Animation Nodes above.
Probably Sverchok one will be vectorized and can do other neat things.
You probably have seen me using this node many times in my AN live noding video.
If there is other thing to add, I might sketch it out.
like that idea. do with color... todo
parking here: https://docs.python.org/3.5/library/colorsys.html this standard module does all these transforms.
colorsys.rgb_to_yiq(r, g, b)
# Convert the color from RGB coordinates to YIQ coordinates.
colorsys.yiq_to_rgb(y, i, q)
# Convert the color from YIQ coordinates to RGB coordinates.
colorsys.rgb_to_hls(r, g, b)
# Convert the color from RGB coordinates to HLS coordinates.
colorsys.hls_to_rgb(h, l, s)
# Convert the color from HLS coordinates to RGB coordinates.
colorsys.rgb_to_hsv(r, g, b)
# Convert the color from RGB coordinates to HSV coordinates.
colorsys.hsv_to_rgb(h, s, v)
# Convert the color from HSV coordinates to RGB coordinates.
maybe this needs a new menu Color
. with the following nodes
@nortikin @ly29 @Kosvor2
i'm tempted to add a feature to the StringsSocket socket type where the socket's draw color is defined as an instance property and can be overwritten in a node's sv_init / process functions. For sockets that are essentially duplicating all functionality of a StringsSocket, but that require (for user friendliness) a slight modification to the socket color .
I don't mind doing this..
i'm considering using the Color()
class to transfer color data.
what?! :)
meh, never!
# rgb, etc, # components
self.outputs['Colors'].sv_set({'kind': self.selected_mode, 'data': series_vec})
Nice, would be good with a graphic color picker as well.
Nice one Zeffii, we can now do Sorting and Filtering of RGB colors. Sorting is an interesting one, I reckon.
we can now do Sorting and Filtering of RGB colors.
hold on.. these nodes aren't functional yet.
I think sv_get
between color(c)->vertices(v)
or color(c)->lists(s)
will need a conversion step to take the data from the color dict..
likewise, vertices(v)->color(c)
, lists(s)->color(c)
would also need such a step to transform their data into a dict...
the problem i have is that FloatVectorProperty won't let us limit min/max per component, this is ok for RGB, HSV, HSL, but will be problematic for YIQ because I and Q have a range between [-1, 1].
The sane thing would probably to use RGB (or RGBA?) internally but allow different inputs types. Then it would be simpler to use it. Compare with cycles
@ly29 i'm probably mistaken (but possibly not) I think the cycles nodes for rgb have a dedicated RGBA color ui template.. for the 4 params. there's no RGBA subtype for FloatVectorProperty
tempted to really make this atomic and just have a colorwheel node too, and keep it out of the socket.. but undecided, depends on taste ..
also, two float vector propties and switch when using YIQ? or skip YIQ, is it really that used?
I am quite happy to ditch YIQ from prominence, and maybe offer a conversion node between spaces instead.
I want a color socket and that color data is like formatted like vertices. RGB is the format for color values by default but other colospaces are also allowed.
A color socket is definitely more sane than hijacking the StringsSocket. I tried StringsSocket, it worked but it felt icky.
i'll make this today, but will hijack the StringsSocket.
If you use vertex like data I say use vertices otherwise stringssocket. It is the generic data type
Yellow color socket is just an existing Edges/Polygons (StringsSocket) with a changeable socket-color property.
current limitation - always have RGBA going through these yellow color sockets. and offer a conversion socket
Brain is not so smart tonight, but I know I can import colorsys and convert HSV into RGB. SN Lite is cool, I just don't understand this fully yet.
Vectorization and Nestiness of Sverchok sometimes taken for granted:
"""
in in_hsv v default=(1,0,0) n=1
out out_rgb v
out out_rgba s
"""
import colorsys as cs
out_rgb = cs.hsv_to_rgb(in_hsv[0][0], in_hsv[0][1], in_hsv[0][2])
out_rgba = [out_rgb[0], out_rgb[1], out_rgb[2], 1.0]
I am currently studying this example of Vectorize of SN Lite: https://github.com/nortikin/sverchok/issues/1005
"""
in in_hsv v default=(1,0,0) n=1
out out_rgb v
out out_rgba s
inject
"""
import colorsys as cs
params = vectorize(in_hsv)
#out_rgb = cs.hsv_to_rgb(in_hsv[0][0], in_hsv[0][1], in_hsv[0][2])
#out_rgba = [out_rgb[0], out_rgb[1], out_rgb[2], 1.0]
# points = [FlowerCurve(*param_set) for param_set in zip(*params)]
out_rgb = [ cs.hsv_to_rgb(*param_set) for param_set in zip(*params) ]
#points = [FlowerCurve(*param_set) for param_set in zip(*params)]
Still wrong, but brute force it....
"""
in hue s default=1.0 n=1
in saturation s default=1.0 n=1
in value s default=1.0 n=1
out out_rgb v
inject
"""
import colorsys as cs
params = vectorize(parameters)
out_rgb = [cs.hsv_to_rgb(*param_set) for param_set in zip(*params)]
keeping digging.
I see.. thanks Zeffii. I was heading this way. Vector Input and this param* was too much, but I noticed by simplifying the input as single and this sort of make sense.
I'll save the list comprehension for other time, but I think below works.
"""
in in_hue s d=1.0 n=1
in in_sat s d=1.0 n=1
in in_val s d=1.0 n=1
in in_alpha s d=1.0 n=1
out out_rgb v
out out_rgba s
inject
"""
import colorsys as cs
params = vectorize(parameters)
#out_rgb = cs.hsv_to_rgb(in_hsv[0][0], in_hsv[0][1], in_hsv[0][2])
#out_rgba = [out_rgb[0], out_rgb[1], out_rgb[2], 1.0]
#print(params[0])
# in case it failed
out_rgb = [1,1,1]
out_rgba = [1,1,1,1]
# this is working
out_rgb = [cs.hsv_to_rgb(*param_set) for param_set in zip(params[0], params[1], params[2])]
out_rgba = []
for rgb in out_rgb:
r,g,b = rgb
out_rgba.append([r,g,b,in_alpha])
At least by doing this example, I understand the inject part a bit better. To be continued...
Additional revision. The vectorized Alpha is now used.
"""
in in_hue s d=1.0 n=1
in in_sat s d=1.0 n=1
in in_val s d=1.0 n=1
in in_alpha s d=1.0 n=1
out out_rgb v
out out_rgba s
inject
"""
import colorsys as cs
params = vectorize(parameters)
#out_rgb = cs.hsv_to_rgb(in_hsv[0][0], in_hsv[0][1], in_hsv[0][2])
#out_rgba = [out_rgb[0], out_rgb[1], out_rgb[2], 1.0]
#print(params[0])
# in case it failed
out_rgb = [1,1,1]
out_rgba = [1,1,1,1]
# this is working
out_rgb = [cs.hsv_to_rgb(*param_set) for param_set in zip(params[0], params[1], params[2])]
#print(params[3])
out_rgba = []
for num, rgb in enumerate(out_rgb):
r,g,b = rgb
out_rgba.append([r,g,b,params[3][num]])
for num, (r, g, b) in enumerate(out_rgb):
out_rgba.append([r, g, b, params[3][num]])
i'll do some more to https://github.com/nortikin/sverchok/tree/colornodes
https://github.com/nortikin/sverchok/pull/1253 pushed to beta nodes for now.
i haven't fully worked out the use_alpha toggle yet.
f.ex: in the color_out node i want it to be able to drop the alpha channel even if the input contains alpha.. no time atm.
please continue conversion here. about the Beta Nodes. https://github.com/nortikin/sverchok/pull/1253
I kind of wish Sverchok has node that deals with Color properly. No need to be vectorized yet, just something simple like the AN one.
If not, I will resort to the Script node, but Sverchok Mini Script node is not yet ready, right?
Anyone recalled someone asking the same question in the "Issues" at some point?
Kind of needing to colorize something.