How to Dynamically Generate Gradient Components from Arbitrary Gradients

Hello gh developers!

I have very little experience in developing gh components, but I can write C# and Python without any issues.

Is there a way to generate a Gradient component in C# or Python from an arbitrary gradient like the one attached?

I want to provide clients with Gradient components that have arbitrary gradients preset.
However, since these gradients change dynamically, I am considering retrieving gradient data from a server and dynamically generating Gradient components.

Is there any method to achieve this?

If dynamic generation is difficult, I think creating a custom gh component that has the same input/output as the Gradient component and a UI that shows what kind of gradient it is might be a good approach.
However, I’m not sure if this method is feasible either.

If you know any way to achieve this or any alternative solutions, please let me know.
Thank you.

you can define custom gradients in the file grasshopper_gradients.xml, usually found in %APPDATA%/Grasshopper.

also have a look at this:

1 Like

I’m not entirely sure I understood the problem, but I wrote a function over here that might help:

1 Like

color gradient tweaks.gh (13.1 KB)


with some tweaks > reverse and append

1 Like

Hello
I have one in NAutilus that read an image, you draw the curve on the image and it makes a Gradient


GradientFromImage.gh (9.5 KB)

2 Likes

I might not be getting it, but some inputs don’t appear to do much/anything:


241025_BlendingColors_Rhino8_00.gh (12.8 KB)

Also, I see you tweaked out original authorship/credits too :face_with_raised_eyebrow:

color gradient tweaks.gh (13.1 KB)
:scream: asked chatgtp to clean and add comments. Ended up removing the comment block, missed that. Lame excuses, but my apologies. Attached version works, had the Boolean input on list instead of item by mistake

1 Like

Hehe, no worries. That sounds exactly like something ChatGPT would do, it even removed the Paul Bourke reference!