For this week’s assignment, we were asked to either create the next iteration of my sketch or create 5 more processing patterns based on the examples given in class. I chose to continue working on my first code, which I had a lot of fun making and want to add more to it.
The first thing I wanted to add was to somehow incorporate color transparency into the code.
I added a gradient of black boxes in the background in the center. It can be drawn over and is now a part of the background. I then wanted to add text indicating what this function does. I added “draw & relax on the top left corner of the code. I then wanted to spice things up by adding a key code where if the user presses “b” the text changes color (from dark green to white)
The code:
PImage img;
void setup() {
size(965, 785);
img = loadImage(“garden.jpg”);
background(img);
textSize(32);
text(“Draw”, 20, 50);
textSize(32);
text(“& Relax”, 50, 100);
fill(0, 0, 0, 255);
rect(230, 100, 440, 100);
fill(0, 0, 0, 191);
noStroke();
rect(230, 250, 440, 100);
fill(0, 0, 0, 127);
rect(230, 400, 440, 100);
fill(0, 0, 0, 95);
rect(230, 550, 440, 100);
}
void draw() {
if (mousePressed == true) {
stroke(255);
strokeWeight(1);
line(mouseX-10, mouseY-20, pmouseX, pmouseY);
}
if (mousePressed == true) {
stroke(255);
strokeWeight(2);
line(mouseX, mouseY, pmouseX-20, pmouseY-10);
}
if (mousePressed == true) {
fill(255);
noStroke();
} else {
fill(0);
}
rect(230, 100, 440, 100);
if (keyPressed) {
if (key == ‘b’ || key == ‘B’) {
fill(255);
}
} else {
fill(23, 48, 40);
}
textSize(32);
text(“Draw”, 20, 50);
textSize(32);
text(“& Relax”, 50, 100);
textSize(32);
fill(0);
text(“Try pressing ‘B'”, 340, 160);
}