mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
Added updated examples from branch
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
size(100, 100, P3D);
|
||||
|
||||
beginShape(POLYGON);
|
||||
fill(0, 255, 0, 255);
|
||||
stroke(0, 0, 255, 255);
|
||||
strokeWeight(5);
|
||||
strokeJoin(ROUND);
|
||||
beginContour();
|
||||
vertex(10, 10);
|
||||
vertex(10, 90);
|
||||
vertex(90, 90);
|
||||
vertex(90, 10);
|
||||
endContour();
|
||||
beginContour();
|
||||
vertex(40, 40);
|
||||
vertex(70, 40);
|
||||
vertex(70, 70);
|
||||
vertex(40, 70);
|
||||
endContour();
|
||||
endShape(CLOSE);
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
size(100, 100, P3D);
|
||||
|
||||
PShape obj = createShape(POLYGON);
|
||||
obj.fill(0, 255, 0, 255);
|
||||
obj.stroke(0, 0, 255, 255);
|
||||
obj.strokeWeight(5);
|
||||
obj.strokeJoin(ROUND);
|
||||
obj.beginContour();
|
||||
obj.vertex(10, 10);
|
||||
obj.vertex(10, 90);
|
||||
obj.vertex(90, 90);
|
||||
obj.vertex(90, 10);
|
||||
obj.endContour();
|
||||
obj.beginContour();
|
||||
obj.vertex(40, 40);
|
||||
obj.vertex(70, 40);
|
||||
obj.vertex(70, 70);
|
||||
obj.vertex(40, 70);
|
||||
obj.endContour();
|
||||
obj.end(CLOSE);
|
||||
|
||||
shape(obj);
|
||||
@@ -0,0 +1,43 @@
|
||||
PShape circle;
|
||||
boolean filled = true;
|
||||
boolean stroked = true;
|
||||
|
||||
public void setup() {
|
||||
size(400, 400, P3D);
|
||||
frameRate(60);
|
||||
|
||||
fill(255, 0, 0);
|
||||
stroke(0, 0, 255);
|
||||
strokeWeight(3);
|
||||
circle = createShape(ELLIPSE, 0, 0, 100, 100);
|
||||
}
|
||||
|
||||
public void draw () {
|
||||
background(0);
|
||||
|
||||
if (5000 < millis()) {
|
||||
if (filled) circle.fill(map(mouseX, 0, width, 255, 0), 0, 0);
|
||||
if (stroked) circle.stroke(0, 0, map(mouseY, 0, height, 255, 0));
|
||||
}
|
||||
|
||||
translate(mouseX, mouseY);
|
||||
shape(circle);
|
||||
}
|
||||
|
||||
void keyPressed() {
|
||||
if (key == 's') {
|
||||
if (stroked) {
|
||||
circle.noStroke();
|
||||
stroked = false;
|
||||
} else {
|
||||
stroked = true;
|
||||
}
|
||||
} else if (key == 'f') {
|
||||
if (filled) {
|
||||
circle.noFill();
|
||||
filled = false;
|
||||
} else {
|
||||
filled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
size(100, 100, P3D);
|
||||
smooth();
|
||||
|
||||
PShape obj = createShape();
|
||||
obj.noFill();
|
||||
obj.stroke(0);
|
||||
obj.strokeWeight(1);
|
||||
obj.vertex(15, 40); // V1 (see p.76)
|
||||
obj.bezierVertex(5, 0, 80, 0, 50, 55); // C1, C2, V2
|
||||
obj.vertex(30, 45); // V3
|
||||
obj.vertex(25, 75); // V4
|
||||
obj.bezierVertex(50, 70, 75, 90, 80, 70); // C3, C4, V5
|
||||
obj.end();
|
||||
|
||||
background(150);
|
||||
shape(obj);
|
||||
Reference in New Issue
Block a user