CSC103 Processing Lab: Solution Sketches Part 1
--D. Thiebaut (talk) 09:35, 13 October 2017 (EDT)
Contents
Solutions
Orange Rectangles
void setup() {
size(480, 480 );
smooth();
}
void draw() {
// ellipse(mouseX, mouseY, 80, 80);
fill( 255, 200, 8 );
rect( mouseX, mouseY, 80, 80 );
}
Swapping mouseX and mouseY
void setup() {
size(480, 480 );
smooth();
}
void draw() {
// ellipse(mouseX, mouseY, 80, 80);
fill( 255, 200, 8 );
rect( mouseY, mouseX, 80, 80 );
}
Squares and Circles
void setup() { size( 500, 500 ); smooth(); } void draw() { fill( 200, 100, 100 ); ellipse( mouseX, mouseY, 80, 80 ); fill( 200, 0, 250 ); rect( mouseX, mouseY, 80, 80 ); }
Squares move Horizontally, Circles Vertically
void setup() { size( 500, 500 ); smooth(); } void draw() { fill( 200, 100, 100 ); ellipse( 100, mouseY, 80, 80 ); fill( 200, 0, 250 ); rect( mouseX, 100, 80, 80 ); }
Random Circles
void setup() { size( 500, 500 ); smooth(); } void draw() { fill( 200, 150, 200 ); ellipse( random(500), random(500), 80, 80 ); // fill( 200, 0, 250 ); // rect( mouseX, 100, 80, 80 ); }
Random Circles with Varying Size and Color
void setup() { size( 500, 500 ); smooth(); } void draw() { fill( 200, random(255), mouseX/2 ); ellipse( random(500), random(500), mouseX, mouseX ); // fill( 200, 0, 250 ); // rect( mouseX, 100, 80, 80 ); }
Random Circles in Square Areas
void setup() { size( 500, 500 ); smooth(); } void draw() { fill( 200, random(255), mouseX/2 ); ellipse( random(100,200), random(100,200), mouseX, mouseX ); fill( 200, mouseX/2, random(255) ); ellipse( random(300,400), random(300,400), mouseX, mouseX ); }