Color pixel spread algorithms

Hi, everyone,

I’m trying to find an efficient algorithm that would allow me to expand a color in a non-regular and more organic way than a growing ellipse.

What I would like to achieve is like a color getting disolved in contact with water. I imagine that could be done, applying alpha properties to a valid pixel expansion algorithm, but first I would like to experiment with any and I’m not finding some valid point from where to start in Processing.

If any of you could give me a clue I would be very grateful. Thanks in advance!

1 Like

Hi Enric :slight_smile:

What would you apply that effect to? Would you paint colors on a white background, and the colors expand on the background? Do you have images to show the effect?

What kind of color do you imagine in contact with water? Water colors spread very fast on the surface with very low opacity. Oil on water behaves different. It clusters and forms circular shapes.

Something that I imagine trying is applying blur on each frame, but the amount of displacement for each pixel depends on something, for example on the brightness of an invisible perlin noise texture, or of a photo, or maybe the hue of the pixel.

Also, is it supposed to be realistic? Or just interesting?

Hi, abe! Thanks for replying. Actually, one of the projects I am working on is a program that reacts to midi information that is entering the system from a digital piano, so it’s a sound visualizer. I would like the different note presences to expand in a haphazardly way related to their midi velocity and their color being able to react to previous note colors. I would like to work with pixels instead of shapes, thats why I was asking about expansion algorithms.
I’ve been trying a first working approach with .frag. but the level of complexity of shaders is still a little too much for me. That’s why I decide to train my brain with algorithms in a more friendly scenario, like processing. Thanks a lot!

Hi @rojele,

Would a modified fluid simulation somehow fit your description ? Daniel Shiffman did a coding challenge on fluid simulation not so long ago. Ripple effect could also be interesting.

1 Like

Sounds nice :slight_smile: But you didn’t answer my questions :slight_smile:

Hi, @solub, a lot of thanks for your suggestion. I will surely give it a try and comment. Cheers!

Hi, Abe, sorry for that, will try to expand my previous answer.

The colors will at first be applied over a black background and over time, react with the other colors. Have in mind that I don’t have an exact idea of what I want, only of the beginning point. I do not have images but the idea appeared looking to a videoclip (that is not generative and even more, its bw) https://www.youtube.com/watch?v=dIwwjy4slI8

The different colors, or the tones applied to a color range would be defined by the pitch of the note, and by the performance time.

It’s not supposed to be realistic, at least not in a first moment. I surely would like it to be interesting.

About the methods for a expansion of the pixels, I was thinking about algorithmic methods for replicate one pixel allowing it to conquer growing areas depending of the time and after a certain threshold time, begin to fade.

Does it answer your questions? Could you please explain your idea of the invisible perlin noise texture brightness as replicating factor?

Thanks a lot!

I really liked solub’s suggestion. Daniel’s code chalange is excellent to start with, bringing colors into the code. And then, playing with this will bring up ideas to work with.

1 Like

Thinking the same, a great starting point. That’s what I asked about, when referring to experiment out of algorithms. Thanks everyone.