some fixes in PShape examples

This commit is contained in:
shiffman
2012-07-19 16:27:02 +00:00
parent 309d95b0cb
commit a3b556dfd2
8 changed files with 12 additions and 9 deletions

View File

@@ -13,6 +13,7 @@ void setup() {
s = createShape();
s.noFill();
s.stroke(255);
s.strokeWeight(2);
// Exterior part of shape
s.beginContour();
s.vertex(-100,-100);

View File

@@ -64,6 +64,5 @@ void draw() {
// Display the group PShape
translate(mouseX, mouseY);
shape(group);
}

View File

@@ -8,13 +8,13 @@
PShape path;
void setup() {
size(640, 360, P2D);
size(640, 360, P3D);
smooth();
// Create the shape
path = createShape();
// Set fill and stroke
path.noFill();
path.stroke(0);
path.stroke(255);
path.strokeWeight(2);
float x = 0;
@@ -29,7 +29,7 @@ void setup() {
}
void draw() {
background(255);
background(51);
// Draw the path at the mouse location
translate(mouseX, mouseY);
shape(path);

View File

@@ -16,6 +16,7 @@ void setup() {
// You can set fill and stroke
star.fill(102);
star.stroke(255);
star.strokeWeight(2);
// Here, we are hardcoding a series of vertices
star.vertex(0, -50);
star.vertex(14, -20);

View File

@@ -15,6 +15,7 @@ class Star {
// You can set fill and stroke
s.fill(102);
s.stroke(255);
s.strokeWeight(2);
// Here, we are hardcoding a series of vertices
s.vertex(0, -50);
s.vertex(14, -20);
@@ -33,8 +34,8 @@ class Star {
void move() {
// Demonstrating some simple motion
x++;
if (x > width) {
x = 0;
if (x > width+100) {
x = -100;
}
}

View File

@@ -13,7 +13,7 @@ void setup() {
smooth();
// Creating the PShape as an ellipse
// The corner is -50,-50 so that the center is at 0,0
circle = createShape(ELLIPSE,-50,-50,100,100);
circle = createShape(RECT,-50,-25,100,50);
}
void draw() {
@@ -21,7 +21,7 @@ void draw() {
// We can dynamically set the stroke and fill of the shape
circle.stroke(255);
circle.strokeWeight(4);
circle.fill(map(mouseX,0,width,0,255)); // Not working in P2D??
circle.fill(map(mouseX,0,width,0,255));
// We can use translate to move the PShape
translate(mouseX, mouseY);
// Drawing the PShape

View File

@@ -9,7 +9,7 @@
Wiggler w;
void setup() {
size(640, 360, P3D);
size(640, 360, P2D);
smooth();
w = new Wiggler();
}

View File

@@ -30,6 +30,7 @@ class Wiggler {
s = createShape();
s.fill(127);
s.stroke(0);
s.strokeWeight(2);
for (PVector v : original) {
s.vertex(v.x, v.y);
}