Assignment 2, Project 1 – Laurel Doak

The colors of the circles and their locations are partly randomized, and partly determined by mouse location. The “grass” effect is a series of narrow green triangles drawn by moving the cursor around. The circles are only drawn at a keypress, while the grass effect is constant. The next step I am tentatively planning is to make the already-drawn circles react to being clicked on. The random lines effect is a highly modified code chunk from the “Random_Lines” example. I saved my random location as a variable so I could use it for both one end of the line and the center of the circle. I also need to keep playing with the color randomization some more to get the color palette I’m looking for.

 

The code, if anyone was curious:

/*
* A project in processing by Laurel Doak:
* Art 150 project 1, UIC
*
* Interactive flower field
* Notes to self: flower click reactions? burning-like effect on specific keypress?
*/

void setup() {
size(500, 500);
background(255);
}
void keyPressed()
{
if (key == ‘s’ )
{
saveFrame(“drawing-####.png”);
}
//Draw a “flower” (maybe it’s a dandelion…). Final version will be more complicated.
if (key == ‘n’)
{
//Random values for location of one end of the line and color of the circle
//(The circle, long-term, is meant to resemble a dandelion puff, if I can get
//a reaction between mouse interaction and already-drawn objects working, I’m
//sure I’ve seen a project that did a similar effect somewhere)
float colorValue = random(170);
float color2 = random(100);
float xCoord = random(50,450);
float yCoord = random(50,450);
stroke(0);
strokeWeight(4);
//Depending on which Left/Right half of the canvas your cursor is currently on, decides
//where the “flower” is going to come up from and draw. Random lines technique
//adapted from the “random lines” example
if (mouseX < 250) {
line(xCoord, yCoord, 500, 500);
noStroke();
fill(255-colorValue, 255-color2, 0);
ellipse(xCoord,yCoord,40,40);
} else {
line(xCoord, yCoord, 0, 500);
noStroke();
fill(255-colorValue, 100-color2, 255-color2);
ellipse(xCoord,yCoord,40,40);
}
}
}

void draw() {
//This chunk draws triangles, creating an effect I thought looked something like grass
fill(#1C8300);
strokeWeight(1);
stroke(#57B43E);
triangle(mouseX,mouseY,mouseX,500,abs(mouseX-15),500);
//A way to wipe the field if you want to start over
if (mousePressed) {
background(255);
}
}