Adobe Illustrator blend tool simulation in Processing

Hey everyone,
just a quick question - is it possible to re-create blending tool via code in processing?
It should look something like this. I am new to processing, I can understand basics and this is something I would love to learn.

Thank you.

Hello @borjan.pavlek

The color gradation can be done using lerpColor().

https://processing.org/reference/lerpColor_.html

However, regarding the morphing of shapes… There is a lerp() function. Though I suspect the results would be more challenging to meet. I could be wrong…

https://processing.org/reference/lerp_.html

Hopefully this helps!
:nerd_face:

2 Likes

Hello,

Here is a simple example that lerps from a square to a triangle:


void setup()
  {
  size(110, 110);
  }
  
void draw()
  {
  float step = map(mouseX, 0, width, 0, 10); //Move mouse on window
    
  strokeWeight(2);
  beginShape();
  vertex(30, 20);
  vertex(85, 20); //Start
  vertex(85, 75); //Start
  vertex(30, 75);
  endShape(CLOSE);
    
// Halfway there!
  strokeWeight(2);
  beginShape();
  vertex(30, 20);
  vertex(85, lerp(20, 50, step/10.0));
  vertex(85, lerp(75, 50, step/10.0));
  vertex(30, 75);
  endShape(CLOSE);  
   
  beginShape();  
  vertex(30, 20);
  vertex(85, 50); // Stop
  vertex(30, 75);
  endShape(CLOSE);  
  }

I made this from code examples in the references and experience.

References:

There are resources (tutorials, examples, references, etc.) at the Processing website:
www.processing.org

Think about how you might do this transition from a square to a circle.

There will be more work to make this a tool!

Start simple and build on that.

Added a for() loop and some color:

:)

2 Likes

I just stumbled upon this in the examples section:
https://processing.org/examples/morph.html
:nerd_face:

2 Likes

Hi everybody!
Thank you so much for all the info. There is a lot I can ue from your comments.
I will post the results if I manage to do it.
Thank you all :slight_smile:

1 Like