Color from Image Sampler - Input Crvs instead of Rectangle component

Hi Fourm - I am trying to input a group of crvs, color them as boundrary Surfaces, from the image sampler colors.

This works simple for the rectangle component. (The problem probably has to do with data trees? I am not familiar with how to fix those yet).

When I try and use a custom pattern I drew, the colors aren’t working (but as you can see the scale component and fillet component are working based on image values)

Could somone help me find out my error?

in script:
(TOP LEFT: script working as regular square grid)
(BOTTOM LEFT: what I would like to work, script with input curves)
(TOP RIGHT: Working with image sampler - is the issue the ratio for w and height when you double click image sampler? not sure)

May take a moment to load :slight_smile:
PatternGridfromImage_progress.gh (524.2 KB)

Image manipulations.3dm (13.3 MB)

Best regards,

This image shows the conventional Rectangle component working (pattern matches image)

This image shows that the pattern does not match the image, and the following image shows that the pattern is correctly being scaled based off of image sampler

tried to open your GH file, please internalize the geometries (curves) of the bottom left definition and attach the image you want to work on :slight_smile:

to better understant what you are aiming for: you want to retrieve the color of only the pixels that lie over a pattern curve that is overlapped over the image?

1 Like

so sorry! I just internalized them

and yes 1 I would want to retrieve the color of the pixels that would align with the pattern crvs

I tried a couple things yesterday but couldn’t figure it out

Best regards!

it works if you plug the output of the image sampler to the preview component:

but there’s a left and bottom line of surfaces with missing color, that depends on the fact that you are providing the image sampler points that range in X (0-to-18.8) and in Y (0-to-28.8), but the image sampler is set with Domain (1-to-19) and (1-to-29):
when you provide a point that has coordinates outside of the Image Domain (for instance all the points with X or Y smaller than 1), because the image sampler is set to Clamp (Clamp = there’s just one single image, infinitely contoured with white transparent pixels outside the Image Domain) you will get transparent white pixels

you don’t see Alpha values unless you ask GH for them using something like split ARGB on which A stays for Alpha → Alpha = 0 = transparent pixel ; Alpha = 255 = full opaque

by splitting your colors in ARGB (I put transparency as last one) you will indeed notice there are several zeroes here and there: those are the transparent ones corresponding to sampled points with x<1 and y<1

by changing the image sampler domain into 0 and connecting the top image sampler color output to the preview looks like everything is working smoothly


PatternGridfromImage_progress_Re.gh (531.9 KB)

1 Like

@inno oh my god! I will check this out. Thank you so much for your reply I learned a lot.

Best regards,

1 Like

PatternGridfromImage_03.gh (13.4 MB)

I was also wondering what the proper workflow might be for displaying Colored surfaces or hatches.

Once baking crvs I thought it would be possible to flip into hatch fills in illustrator - at this many crvs Illustrator won’t let you switch the lineweight button to fills (can you do this in rhino?)

Here the curves are baked with color

I was thinking, I could screencap the surfaces as geo preview - but that would be more low res

I thought maybe i could bake with color, but couldn’t figure that out

Or maybe baking as mesh with color would be better than polysrf? - - - but would it possible to bake a reduced mesh before computing a high triangle mesh count that would explode my pc?

Best regards,

I may have figured out an alternative - I was able to bake a reduced mesh using pufferfish component instead of trying to bake a hatch

so that I could render the colored mesh instead of having a hatch, although it would be nice to have a scalable vector graphic hatch pattern - if someone finds a way that would be greatly appreciated!

this is more an Illustrator thing :slight_smile: I had similar problems for a project with thousands of tiny circles in different colors, the issue with alternating fills and stroke color in illustrator did not depend on the thing that the circles were many, but that you can invert fill/stroke only if each and all items in your current selection share the very same stroke/fill color

in Rhino you could create a layer for each color, and each layer should only have curves of that exact color (you can do that with Human or Elefront plugins, or by coding)
at that point in Illustrator you can go layer after layer, select all items on that layer, and flip stroke/fill
in my case I had something like 15 different colors in total, so it wasn’t that painful

[edit] you can also just export your curves to illustrator without dividing in layers → open file in illustrator → manually select one single curve in the drawing → Select menu → select similar → stroke color → then click on the flip stroke/fill… rinse and repeat for each color

pretty sure it can also be scripted in Illustrator to fully automate the process, there must be something around on the internet

[edit 2] this only works with curves of same color in the selection → Shift+X
Swap the Fill and Stroke | Killer Tips for Working With Color in InDesign CS/CS2 | Peachpit.

[edit 3] this: Swapping fill and stroke on multiple objects - Adobe Support Community - 2233202

1 Like

Thanks so much @inno these are all wonderful suggestions - looking forward to testing them all!

PatternGridfromImage_04.gh (13.4 MB)
updated file