Filling complex shape - followup

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();

Hello,

Please format your code:
https://discourse.processing.org/faq#format-your-code

Your related post is here:

This is my first time using curveVertex() as well.
Read the reference carefully:
https://processing.org/reference/curveVertex_.html

I added the first and last guide points:
image

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

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

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.

image

:)

1 Like