//Jacky Lococo
//jlococo
//Section C
var photoFace; //stores the image
var size = 10 //stores size of the images
function preload() {
photoFace = loadImage('https://i.imgur.com/vdN43xy.png?1');
}
function setup() {
createCanvas(345, 400);
imageMode(CENTER);
noStroke();
photoFace.loadPixels();
}
function draw() {
background(255);
drawPixleate();
fill(0);
textSize(15)
text('P R E S S', mouseX, mouseY); // writes press
size = map(mouseX, 0, width, 10, 50); // will map the size of the
if (size == 0) size = 1;
}
function drawPixleate(){
for (var y = 5; y < height + 50; y += size) {
for (var x = 5; x < width + 50; x += size) {
print(photoFace.width);
var pix = photoFace.get(x, y); //extracts color from the image
fill(pix);
if(mouseIsPressed){
ellipse(x, y, size, size); //ellipse instead of rectangles when mouse is pressed
} else {
rect(x, y, size, size);//rectangled when mouse is not pressed
}
}
}
}
Project 09: Portrait
sketch