ghou-Project-09-Portrait

sketch

//Grace Wanying Hou
//15-104 Section D
//ghou@andrew.cmu.edu
//Project 09

//global variables
var sw = [];
var a = 0;
var r = 2;
var rx = [];
var ry = [];

function preload(){
    var imageurl = "https://i.imgur.com/S483jxr.jpg";
    dp = loadImage(imageurl);
}

function setup(){
    createCanvas(380,300);
    dp.loadPixels();
    background(240,245,250);
    for (var i=0; i<10; i++){ //randomizing where spirals are
        rx[i] = random(380);
        ry[i] = random(300);
        sw[i] = random(2,8);
    }
}

function draw(){
    noStroke();
    a += 0.1;
    r += 0.1;
//setting up spirals 
    var x = rx[0] + r * -cos(a);
    var y = ry[0] + r * sin(a);
    var pointcolour = dp.get(floor(x),floor(y));
    fill(pointcolour);
    ellipse(x,y,sw[0]);
    
    var x1 = rx[1] + r * -cos(a);
    var y1 = ry[1] + r * sin(a);
    var pointcolour1 = dp.get(floor(x1),floor(y1));
    fill(pointcolour1);
    ellipse(x1,y1,sw[1]);
    
    var x2 = rx[2] + r * -cos(a);
    var y2 = ry[2] + r * sin(a);
    var pointcolour2 = dp.get(floor(x2),floor(y2));
    fill(pointcolour2);
    ellipse(x2,y2,sw[2]);

    var x3 = rx[3] + r * -cos(a);
    var y3 = ry[3] + r * sin(a);
    var pointcolour3 = dp.get(floor(x3),floor(y3));
    fill(pointcolour3);
    ellipse(x3,y3,sw[3]);
    
    var x4 = rx[4] + r * -cos(a);
    var y4 = ry[4] + r * sin(a);
    var pointcolour4 = dp.get(floor(x4),floor(y4));
    fill(pointcolour4);
    ellipse(x4,y4,sw[4]);
    
    var x5 = rx[5] + r * cos(a);
    var y5 = ry[5] + r * sin(a);
    var pointcolour5 = dp.get(floor(x5),floor(y5));
    fill(pointcolour5);
    ellipse(x5,y5,sw[5]);

    var x6 = rx[6] + r * cos(a);
    var y6 = ry[6] + r * sin(a);
    var pointcolour6 = dp.get(floor(x6),floor(y6));
    fill(pointcolour6);
    ellipse(x6,y6,sw[6]);
    
    var x7 = rx[7] + r * cos(a);
    var y7 = ry[7] + r * sin(a);
    var pointcolour7 = dp.get(floor(x7),floor(y7));
    fill(pointcolour7);
    ellipse(x7,y7,sw[7]);
    
    var x8 = rx[8] + r * cos(a);
    var y8 = ry[8] + r * sin(a);
    var pointcolour8 = dp.get(floor(x8),floor(y8));
    fill(pointcolour8);
    ellipse(x8,y8,sw[8]);
    
    var x9 = rx[9] + r * cos(a);
    var y9 = ry[9] + r * sin(a);
    var pointcolour9 = dp.get(floor(x9),floor(y9));
    fill(pointcolour9);
    ellipse(x9,y9,sw[9]);
    
}

I was a little inspired by the post-expressionism art period and Van Gogh’s paintings and his swirling brush strokes to create this portrait. I think the most difficult part of this project was setting up the variables. Overall I really enjoyed working on this; I wanted to set up a for() loop to create the 10 spirals but in the end I was unsuccessful although I am still thoroughly proud of my work.

Leave a Reply