Interactive Authoring (Fixed Code)

The following are the fixed versions of 5 flawed codes.

Code 1:

void setup() {

size(1920, 1080);
smooth();
}

void draw() {

background(255);
ellipseMode(CENTER);
rectMode(CENTER);

stroke(0);
fill(175);
rect(mouseX, mouseY, 20, 100);
stroke(0);
fill(255);
ellipse(mouseX, mouseY-30, 60, 60);
fill(mouseX, 0, mouseY);
ellipse(mouseX-19, mouseY-30, 16, 32);
ellipse(mouseX+19, mouseY-30, 16, 32);
stroke(0);
line(mouseX-10, mouseY+50, pmouseX-10, pmouseY+60);
line(mouseX+10, mouseY+50, pmouseX+10, pmouseY+60);
}
void mousePressed() {
println(“Take me to your leader!”);
}

Code 2:

void setup() {
size(200,200);
background(255);
}
void draw() {
}
void mousePressed() {
stroke(0);
fill(175);
rectMode(CENTER);
rect(mouseX,mouseY,16,16);
}
void keyPressed() {
background(255);
}

Code 3:

color RanColor;
boolean goCrazy;

void setup() {
size(300, 300);
RanColor = color(200, 10, 189);
}

void draw() {
background (RanColor);
if (goCrazy == true) {
RanColor = color(random(255), random(255), random(255));
}
}

void mousePressed() {
goCrazy = true;
}

void mouseReleased() {
goCrazy = false;
}

Code 4:

int circleX = 0;
int circleY = 100;
void setup() {
size(200, 200);
}
void draw() {
background(255);
stroke(0);
fill(175);
ellipse(circleX, circleX, 50, 50);
circleX = circleX + 1;
}

Code 5:

float g;
float b;
float a;
float diam;
float x;
float y;
float r;
void setup() {
size(720, 480);
background(0);
smooth();
}
void draw() {
// Fill all variables with random values
r = random(255);
g = random(255);
b = random(255);
a = random(255);
diam = random(20);
x = random(width);
y = random(height);
// Use values to draw an ellipse
noStroke();
fill(r, g, b, a);
ellipse(x, y, diam, diam);
}

This entry was posted in Non-Timebased and tagged , . Bookmark the permalink.

Leave a comment