/* Austin Garcia
Section C
aegarcia@andrew.cmu.edu
Assignment or Project
*/
var originalImage;
function preload() {
var myImageURL = "https://i.imgur.com/UdorMH0.jpg";
originalImage = loadImage(myImageURL); //load image
}
function setup() {
createCanvas(500, 500);
background(0);
originalImage.loadPixels();
frameRate(1000);
}
function draw() {
var px = random(width); //x coordinate
var py = random(height); //y coordinate
var ix = constrain(floor(px), 0, width-1);
var iy = constrain(floor(py), 0, height-1);
var locationColor = originalImage.get(ix, iy); //get pixel color
var rectSizeX = random(10, 50)
var rectSizeY = 2
noStroke();
fill(locationColor);
rect(px, py, rectSizeX, rectSizeY);
var theColorAtTheMouse = originalImage.get(mouseX, mouseY);
stroke(theColorAtTheMouse);
ellipse(pmouseX, pmouseY, 1, 2*height + mouseY);
}
I wanted to explore vertical and horizontal lines converging to create this image my girlfriend took of me over the summer. I had the code generate short horizontal bars while having the mouse draw long vertical bars.