# "Blend" two Shapes in processing

Hey, English isn’t my first language so please be kind. I do by best and hope you understand my problem. This is my first processing project and i have completely no idea what i’m doing or have to do… I want to “Blend” the circle and the outline together with 20 lines. (like in the picture, which i do with illustrator and the blend-tool) The code you can see, is my “start” but I’m pretty sure it isn’t right or even the right way to solve my problem.
Thank you for every help or maybe directly the right code? Hi @Kiraw! Your English is good. Check out the Morph Processing example. The idea is to represent your two curves as two lists of points, and the blend is achieved by using linear interpolation between the points in curve_1 with the points in curve_2.

Hi,
I’m german too here you go :

``````float scale = 0.3;
int shapelength = 12;
int iterations = 10;

float[][][] shape_coords = new float[shapelength];

void setup() {
size(1152, 648); //skaliert mit * 0.3
background (255);

// innen (2)
shape_coords = 1500 * scale;
shape_coords = 900 * scale;
shape_coords = 1500 * scale;
shape_coords = 900 * scale;
shape_coords = 1500 * scale;
shape_coords = 900 * scale;
shape_coords = 1500 * scale;
shape_coords = 900 * scale;
shape_coords = 1500 * scale;
shape_coords = 900 * scale;
shape_coords = 1500 * scale;
shape_coords = 900 * scale;
shape_coords = 1500 * scale;
shape_coords = 900 * scale;
shape_coords = 1500 * scale;
shape_coords = 900 * scale;
shape_coords = 1500 * scale;
shape_coords = 900 * scale;
shape_coords = 1500 * scale;
shape_coords = 900 * scale;
shape_coords = 1500 * scale;
shape_coords = 900 * scale;
shape_coords = 1500 * scale;
shape_coords = 900 * scale;

//außen (1)
shape_coords = 1520 * scale;
shape_coords = 485 * scale;
shape_coords = 2020 * scale;
shape_coords = 1150 * scale;
shape_coords = 2535 * scale;
shape_coords = 775 * scale;
shape_coords = 2880 * scale;
shape_coords = 1130 * scale;
shape_coords = 3100 * scale;
shape_coords = 1633 * scale;
shape_coords = 2720 * scale;
shape_coords = 1770 * scale;
shape_coords = 2170 * scale;
shape_coords = 1275 * scale;
shape_coords = 1365 * scale;
shape_coords = 1760 * scale;
shape_coords = 725 * scale;
shape_coords = 1160 * scale;
shape_coords = 1520 * scale;
shape_coords = 485 * scale;
shape_coords = 2020 * scale;
shape_coords = 1150 * scale;
shape_coords = 2880 * scale;
shape_coords = 1130 * scale;
}

void draw() {

strokeWeight (2 * scale);

//malen
for (int j = 0; j < iterations; j++) {

stroke (100 + float(j)/float(iterations) * 100);

beginShape();
noFill();
for (int i = 0; i < shapelength; i++) {
curveVertex(lerp(shape_coords[i], shape_coords[i], float(j)/float(iterations)), lerp(shape_coords[i], shape_coords[i], float(j)/float(iterations)));
}
endShape();
}
}

``````

I was a bit lazy with the circle. Also your screen resolution didn’t fit mine so I changed it a bit…

1 Like

@MxFxM It’s awesome that you’re trying to help, but please do not post full code solutions. Instead, try to guide people through solving their own problems. After all, you wouldn’t just do somebody else’s homework for them, right?

3 Likes

He (or she) asked for it.
Also I don’t have much to do so I might as well programm the whole thing. If I just give a hint he might ask again and I would have to answer again (for that I don’t have the time. programming something this simple doesn’t take me too long).

I would Thanks a lot! I just have to understand what you did and change it so my model.

@Kevin To be honest a guide through solving my problem woulnd’t help me. Like I said, I have completely no plan from processing. I have the code now, but this isn’t my whole project and I also have to understand what the code is doing. So he didn’t my homework, he just helped me. First thing I did was transferring your vertices in an array instead of having them one by one so I can iterate through it with the inner for loop.

Then I added a second shape (the circle) with the same amount of vertices as the first shape. In this step it’s important to match the positions of the vertices (e.g. you dont want the upper right corner to go towards the lower left or maybee you do I don’t know).

Next step is to find a point between the outer shape and the inner one. I used the lerp() function for that. You can look it up in the reference, it’s pretty straight forward.
Depending on how many steps you want inbetween the shapes you will have to do that muliple times (outer for loop which does iterations cycles).

For visuals I also changes the color of the line going inwards.

I get it! But one more question, why I cannot see the inner circle as a circle? I can only see the first “shape”?
“innen (2)” define only the coordinates of the first point of the circle or am i wrong? But why it isn’t a real circle?

I guess if you make a real circle instead of a point you would see it but I don’t have the time to try that.

You’re wrong. It defines the whole circle however the circle is just a point.

Please note that the official policy of these forums is to not give out full code solutions like this, and to not do other people’s homework for them.

Continued ignoring of this policy will result in a ban.

It’s great that you want to help, and I truly appreciate your time. But offering full code solutions short-circuits the most important thing we can help with here: the practice of breaking a problem down and solving it one step at a time.

Again, I advise you to read this guide:

I don’t want to derail this thread, so if you want to discuss this further, please post in the site feedback category.

2 Likes