Project 9

sketchDownload
let img;


function preload() {
    img = loadImage("https://i.imgur.com/CPxq6MI.jpg");
}


function setup() {
    createCanvas(480, 480);
    background(110, 16, 0);
    img.resize(width, height);
    img.loadPixels();
    imageMode(CENTER);
    //image(img, 240, 240);
    frameRate(1000);
}

function draw() {
    let x = floor(random(img.width)); //x position of pixels
    let y = floor(random(img.height)) //y position of pixels
    let shapePixel = img.get(x, y); //get pixels from photo
    let textPixel = img.get(mouseX, mouseY); //get pixel from mouse location
    //randomly generated pixels that fill up the page
    let shapeR = random(15);
    noStroke();
    fill(shapePixel);
    circle(x, y, shapeR);


    //draw star shapes when mouse is pressed
    if (mouseIsPressed) { 
        fill(textPixel);
        textSize(random(5, 40));
        text('★', mouseX, mouseY); //star shape follows mouse
    }
}

//erases when double click
function doubleClicked() {
    fill(110, 16, 0);
    circle(mouseX, mouseY, 70);
}

This project is dedicated to celebrating my grandfather, who had just gotten his medal for 70 year anniversary since serving in the war. As you press your mouse across the screen stars will follow, and if you double click you can erase part of the drawing.

Leave a Reply