mirror of
https://github.com/processing/processing4.git
synced 2026-01-29 11:21:06 +01:00
39 lines
609 B
Plaintext
39 lines
609 B
Plaintext
/**
|
|
* PathPShape
|
|
*
|
|
* A simple path using PShape
|
|
*/
|
|
|
|
// A PShape object
|
|
PShape path;
|
|
|
|
void setup() {
|
|
size(640, 360, P2D);
|
|
smooth();
|
|
// Create the shape
|
|
path = createShape();
|
|
path.beginShape();
|
|
// Set fill and stroke
|
|
path.noFill();
|
|
path.stroke(255);
|
|
path.strokeWeight(2);
|
|
|
|
float x = 0;
|
|
// Calculate the path as a sine wave
|
|
for (float a = 0; a < TWO_PI; a+=0.1) {
|
|
path.vertex(x,sin(a)*100);
|
|
x+= 5;
|
|
}
|
|
// The path is complete
|
|
path.endShape();
|
|
|
|
}
|
|
|
|
void draw() {
|
|
background(51);
|
|
// Draw the path at the mouse location
|
|
translate(mouseX, mouseY);
|
|
shape(path);
|
|
}
|
|
|