Keywords changes, currently not entirely working

This commit is contained in:
Casey Reas
2012-12-09 15:35:57 +00:00
parent 46e3f44d1f
commit b9d9505827
15 changed files with 441 additions and 460 deletions
@@ -15,13 +15,10 @@ void setup() {
s.stroke(255);
s.strokeWeight(2);
// Exterior part of shape
s.beginContour();
s.vertex(-100,-100);
s.vertex(100,-100);
s.vertex(100,100);
s.vertex(-100,100);
s.vertex(-100,-100);
s.endContour();
// Interior part of shape
s.beginContour();
@@ -29,11 +26,10 @@ void setup() {
s.vertex(10,-10);
s.vertex(10,10);
s.vertex(-10,10);
s.vertex(-10,-10);
s.endContour();
// Finishing off shape
s.end();
s.end(CLOSE);
}
void draw() {
@@ -6,21 +6,25 @@
// A Star object
Star s;
Star s1, s2;
void setup() {
size(640, 360, P2D);
smooth();
// Make a new Star
s = new Star();
s1 = new Star();
s2 = new Star();
}
void draw() {
background(51);
// Display the star
s.display();
// Move the star
s.move();
s1.display(); // Display the first star
s1.move(); // Move the first star
s2.display(); // Display the second star
s2.move(); // Move the second star
}
@@ -6,16 +6,17 @@ class Star {
PShape s;
// The location where we will draw the shape
float x, y;
float speed;
Star() {
x = 0;
y = height/2;
x = random(100, width-100);
y = random(100, height-100);
speed = random(0.5, 3);
// First create the shape
s = createShape();
// You can set fill and stroke
s.fill(102);
s.stroke(255);
s.strokeWeight(2);
s.fill(255, 204);
s.noStroke();
// Here, we are hardcoding a series of vertices
s.vertex(0, -50);
s.vertex(14, -20);
@@ -33,7 +34,7 @@ class Star {
void move() {
// Demonstrating some simple motion
x++;
x += speed;
if (x > width+100) {
x = -100;
}
@@ -17,7 +17,7 @@ class Polygon {
// Simple motion
void move() {
y+=speed;
y += speed;
if (y > height+100) {
y = -100;
}
@@ -15,8 +15,8 @@ void setup() {
smooth();
// Make a PShape
PShape star = createShape();
star.noStroke();
star.fill(0,127);
star.stroke(0);
star.vertex(0, -50);
star.vertex(14, -20);
star.vertex(47, -15);
@@ -19,13 +19,13 @@ void setup() {
shapes[0] = createShape(ELLIPSE,0,0,100,100);
shapes[0].fill(255,127);
shapes[0].stroke(0);
shapes[0].noStroke();
shapes[1] = createShape(RECT,0,0,100,100);
shapes[1].fill(255,127);
shapes[1].stroke(0);
shapes[1].noStroke();
shapes[2] = createShape();
shapes[2].fill(0,127);
shapes[2].stroke(0);
shapes[2].noStroke();
shapes[2].vertex(0, -50);
shapes[2].vertex(14, -20);
shapes[2].vertex(47, -15);
@@ -38,7 +38,6 @@ void setup() {
shapes[2].vertex(-14, -20);
shapes[2].end(CLOSE);
// Make an ArrayList
polygons = new ArrayList<Polygon>();
@@ -52,7 +51,7 @@ void setup() {
}
void draw() {
background(51);
background(102);
// Display and move them all
for (Polygon poly : polygons) {