"gradient" fill

tom's Avatar


27 Jun, 2024 11:08 AM

i am trying to colorize circles in a grid with gradient based on three rgb colors - with those i have created a range of values.

but so far i have only managed to colorize a grid with a consistent number of points in each row. (eg. the amount of colors in the range is the same as the number of rows in the grid)
as i am generating (rasterized) shapes based on this grid, the number of points in the rows is not consistend anymore - and this workflow (of course) breaks.

what could be a possible approach?

the idea is to somehow either
a) limit the duplication of each color to the amount of points in the corresponding row.
b) color based on the y-position of each point

- different shapes, with a different amount of rows are generated

  • i am not able to access the y-position key of an ellipse

any ideas?

  1. Support Staff 1 Posted by john on 27 Jun, 2024 03:15 PM

    john's Avatar


    To access the y-position of an ellipse (or any other path) just feed it into a centroid node to get its center point, and then feed that into a lookup node with the key set to y.

    Once you have the y value for each dot, you can assign each row a color by using a slice node to slice one color from the list of colors forming your gradient.

    You can use a convert_range node to convert the range of Y values to a sequence from 0 to the number of colors in your gradient. You can then feed that into the start parameter of a slice node to assign a color to each dot. Dots with the same Y value will get the same color.

    In case that is not clear, I have attached a demo showing the basic technique (see screenshot and zipped file).

    • I create a collection of dots in the shape of a lower case a
    • I use the Y values of those dots and a convert_range node to find a sequence number within the gradient for each dot
    • I form the gradient by extending the 3 colors from your example into a color list using my palette node
    • Then I use a slice node to pick each sequence number from the gradient list and feed that into a colorize node

    Hope that helps. Let me know if you have any more questions.


  2. 2 Posted by tom on 28 Jun, 2024 01:51 PM

    tom's Avatar

    hey John, thanks a lot!
    i managed to find a solution myself, but yours is way more efficient.

    for my solution i used this custom node to count the points in each row based on their y-attribute.


    and then i wrote two more custom nodes:
    - one for remapping rgb-values based on min, mid and max by an amount of n - one for duplicating these in a list based on the count

    all the best

  3. tom closed this discussion on 29 Jun, 2024 12:52 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

23 Jul, 2024 04:46 PM
22 Jul, 2024 07:50 AM
11 Jul, 2024 03:48 PM
28 Jun, 2024 01:51 PM
27 Jun, 2024 02:56 PM


27 Jun, 2024 01:57 PM
26 Jun, 2024 08:17 PM
26 Jun, 2024 11:35 AM
24 Jun, 2024 02:42 AM
24 Jun, 2024 12:46 AM
23 Jun, 2024 08:07 AM