project7
This was pretty fun to think of different ways to create a portrait. Going off the pointillism idea, I tried to think of different shapes that could be used and experiment. I decided to use mousePressed() to restart with new shapes. I feel they all came out pretty interesting and all the shapes relate to each other differently.
//Rachel Legg / rlegg / Section C
var img;
var option = 1;
//load image
function preload(){
//photo of me
img = loadImage("https://i.imgur.com/wtr45Lt.jpg");
}
function setup() {
createCanvas(450, 400);
background(0);
img.resize(width, height);
img.loadPixels();
//fast frame rate
frameRate(500);
}
function draw() {
//have random x & y for portrait
var x = floor(random(0, 450));
var y = floor(random(0, 400));
//use color from pixel
var color = img.get(x, y);
//smaller shapes leads to more detail
var s = random(3, 10);
// #4 is used for each pixel
if (option == 1){
//have shape pop as pixels
fill(color);
//outline of light-colored stroke
stroke("lightyellow");
strokeWeight(.5);
stroke(color);
textSize(s);
text("4", x, y);
//switch 4 to circle option w/ mousePressed
} else if (option == 2){
//have shape pop as pixels
fill(color);
//outline of light-colored stroke
stroke("lightyellow");
strokeWeight(.5);
circle(x, y, s);
//switch circle to triangle option w/ mousePressed
} else if (option == 3){
//have shape pop as pixels
fill(color);
noStroke();
strokeWeight(.5);
triangle(x, y, x - s, y + s, x + s, y + s);
}
}
function mousePressed(){
option++;
if(option > 3){
option = 1;
}
background(0);
}