rkk16
May 21, 2020, 4:16pm
1
Please find my code below. Trying to create a lip but it cuts halfway for some reason, can someone please explain why?
int x = 100;
fill(255,0,0);
beginShape();
curveVertex(-20+x,80);
curveVertex(30+x,90);
curveVertex(80+x,90);
curveVertex(140+x,80);
curveVertex(80+x,120);
curveVertex(30+x,120);
curveVertex(-20+x,80);
//vertex(20+x,65);
//bezierVertex(20+x,75, 100+x, 75,100+x,65);
//bezierVertex(20+x,70, 100+x, 70, 20+x,65);
// etc;
endShape();
glv
May 21, 2020, 5:30pm
2
Hello,
Please format your code:
https://discourse.processing.org/faq#format-your-code
Your related post is here:
How do we fill in a complex circular shape like a lip?
ie [image]
I know how to draw the Bezier/curve lines but how do we fill in 2 Bezier curves that join at 2 vertices?
This is my first time using curveVertex() as well.
Read the reference carefully:
I added the first and last guide points:
I also plotted the points to see where they were.
This may not be the result you are expecting.
Consider:
Multiple shapes.
Overlapping shapes with background over shape
There may be other creative solutions out there.
:)
2 Likes
rkk16
May 21, 2020, 7:40pm
3
Thanks! It works alright, I’m trying to interpolate between two values to animate lip movements. But that’s doesn’t work, any ideas how to? I’m using Lerp to recalculate vertex points and applying curveVertex repeatedly until the final value is reached
glv
May 21, 2020, 7:56pm
4
Hello,
Mostly a hint for helping you develop code:
void setup()
{
size(500, 200, P2D);
}
void draw()
{
background(0);
// Flipped the y axis
scale(1, -1);
translate(200, -height);
//Useful tool:
float x = map(mouseX, 0, width, -50, 50);
float y = map(mouseY, 0, height, -50, 50);
// Your original shape with missing half and x and y offsets added.
fill(255, 255, 0);
noStroke();
beginShape();
curveVertex(-20+x,80);
curveVertex(30+x,90+y);
curveVertex(80+x,90);
curveVertex(140+x,80+y);
curveVertex(80+x,120);
curveVertex(30+x,120);
curveVertex(-20+x,80);
endShape(CLOSE);
}
I did not add missing guide points.
Please edit your original post and format your code properly.
:)
1 Like