
A)
void setup() {
size(200,200);
smooth();
}
void draw() {
background(255);
stroke(0);
fill(175);
ellipse(50,50,50,50);
ellipse(150,50,50,50);
ellipse(50,150,50,50);
ellipse(150,150,50,50);
}
B)
void setup() {
size(200,200);
smooth();
}
void draw() {
background(255);
stroke(0);
line(100,0,100,100);
line(100,100,0,200);
line(100,100,200,200);
}
C)
void setup() {
size(200,200);
smooth();
}
void draw() {
background(255);
stroke(0);
rectMode(CENTER);
fill(175);
rect(100,100,175,175);
fill(255);
ellipse(100,100,75,75);
}
Example Step 3 Answer:
float centerX = 100;
float centerY = 100;
void setup() {
size(200,200);
smooth();
}
void draw() {
background(255);
stroke(0);
line(width/2,0,centerX,centerY);
line(centerX,centerY,0,height);
line(centerX,centerY,width,height);
centerX += random(-1,1);
centerY += random(-1,1);
centerX = constrain(centerX,0,width);
centerY = constrain(centerY,0,height);
}
Hi I’ve attempted adding variable to A) with the intention of making it track from left to right but nothing is happening. What am I doing wrong?
int circleX = 50;
int circleY = 50;
int circleSize = 50;
int circleFill = 0;
int speed = 1;
// basic setup
void setup() {
size(200,200);
background(255);
smooth();
}
void draw() {
stroke(0);
fill(0);
// circle top left
ellipse(circleX,circleY,circleSize,circleSize);
// circle top right
ellipse(150,50,50,50);
// circle bottom left
ellipse(50,150,50,50);
// circle bottom right
ellipse(150,150,50,50);
}
void move() {
circleX = circleX + speed;
if (circleX > width) {
circleX = 10;
}
}
void display() {
fill(circleFill);
ellipse(circleX,circleY,circleSize,circleSize);
}
also do you know how I would create the > symbol on a mac because at the moment I can only copy and paste it. I’ve tried alt + every key available but still no joy
Thank you
Comment by Dolsign — January 6, 2010 @ 7:26 am
You created the move() and display() functions, but never call them anywhere. Only draw() is called automatically by Processing so you’ll need to explicitly call your user-defined functions, i.e.
void draw() { move(); // etc. }‘>’ is SHIFT-PERIOD on my mac.
Comment by Daniel Shiffman — January 7, 2010 @ 9:01 am