Project 9: Portrait

sketch
var picture;
var size = 20
var x = 0;
var y = 0;

//load image
function preload() {
    picture = loadImage("https://i.imgur.com/bOywqob.jpg");
    
}

function setup() {
    createCanvas(600, 500);
    background(255,0,255);

    //load pixels from image
    picture.loadPixels();
}

function draw() {
  //pixel colors of the image at x and y position
    var col = picture.get(x, y);
        fill(col);
        noStroke();
        rect(x, y, size);
        var xpos = mouseX - x;
        var ypos = mouseY - y;
        x += xpos / 5;
        y += ypos / 5;  
    }
function mousePressed() {
  size += 10
  
}

Leave a Reply