For homework, we were assigned to create our own code for a program which we could use to draw.
I began by choosing a nice background color for my canvas by using photoshop to see which colors I wanted and the RGB color that it would need. I originally wanted my background color to be solid much like the collage I made last class.
After experimenting and researching how to make the drawing tool change color if the mouse was pressed, I made the code that would cause the rectangle to change color anytime I pressed it. The box would follow the cursor.
The Code I Made originally:
void setup() {
size(1000, 670);
noSmooth();
fill(173, 113, 235);
background(173, 113, 235);
}
void draw() {
if (mousePressed) {
stroke(20);
fill(12, 34, 560);
} else {
stroke(0);
fill(34, 280, 123);
}
rect(mouseX, mouseY, pmouseX, pmouseY);
stroke(30);
}
However, I felt like using a rectangle as the tip of the drawing tool was not efficient so I decided to change my code completely and change it so that the lines only draw when the ouse is pressed.
I then decided to change the line so that it would be more textured and interesting. I also played around with the color of the line to see which one I like.
Lastly, I changed the background into a photo so that I could draw over it (just like what I did for my collage). This took me a while to get but in the end, I liked how it turned out. I changed the color of the drawing tool back to white because I felt like it stood out more in front of the photo.
The Final Drawing Tool Code:
PImage img;
void setup() {
size(965, 785);
img = loadImage(“garden.jpg”);
background(img);
}
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);
}
}