Achieving a noodle shape

Hello,

I created a simple shape with curveVertex() and overlaid them to show an outline.

A line is a shape. :)

My first version for testing:

Code
// Worm
// v1.0.0
// GLV 2021-03-28

float amp;

void setup() 
	{
  size(640, 360);
	}

void draw() 
	{
  amp = map(mouseX, 0, width, 3*height/4, height/4);
  
  background(255);
  strokeWeight(20);
  noFill();
  stroke(0);
  myShape();

  strokeWeight(15);
  stroke(255);
  myShape();
	}

void myShape()
  {
  beginShape();
  curveVertex(width/8,  height/2);
  curveVertex(width/8,  height/2);;
  curveVertex(width/8 + 7*width/32,  amp);
  curveVertex(3*width/4 - 3*width/32,  height -amp);  
  curveVertex(7*width/8,  height/2);
  curveVertex(7*width/8,  height/2);
  endShape();
  }

image

I then replaced all the fixed co-ordinates with variables and manipulated them (algebra and trigonometry) with code.

Not quite there yet but a work in progress:
canvas

:)

2 Likes