Ian Kaneko – 09 – Portrait

ikaneko Portrait

var img;
var gScale = 0.14; // Scale the image size down
var size = 5; // Size of all the circles and squares

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

function setup() {
    createCanvas(img.width * gScale, img.height * gScale);
    background(255);
    frameRate(60);
    img.loadPixels();

}

function draw() {
    //Draws small circles and squares. The circles are tinted red and the squares are blue

    var cx = random(img.width); 
    var cy = random(img.height);
    var dotColor = img.get(cx, cy);
    var db = brightness(dotColor); // Gets the grayscale value of the pixel

    noStroke();
    fill(db + 150, db + 100, db + 100); // Turns all of the circles a red/brown
    circle(cx * gScale, cy * gScale, size);
    


    var sx = random(img.width);
    var sy = random(img.height);
    var squareColor = img.get(sx, sy);
    var sb = brightness(squareColor);

    fill(sb + 100, sb + 100, sb + 150); // Turns the squares blue
    square(sx * gScale, sy * gScale, size);



    var gx = random((mouseX - 15) / gScale, (mouseX + 15) / gScale); // creates a circle within 30 pixels of the mouse
    var gy = random((mouseY - 15) / gScale, (mouseY + 15) / gScale);
    greenDotColor = img.get(gx, gy);
    var gb = brightness(greenDotColor);

    fill(gb + 100, gb + 150, gb + 100); // Turns these circles green
    circle(gx * gScale, gy * gScale, size);

}

For this project I used a quick picture I took of myself as the base. I played around a bit with what I could do with the colors. Using the brightness feature I basically turned the picture black and white, then added in contrasting colors. Red circles and blue squares will randomly appear to start filling in the picture. Green circles will begin to fill in the picture in an area close to your mouse.

Portrait after about 10 – 20 seconds
Portrait after a few minutes
Original picture of myself

Yoshi Torralva—Project 9—Portrait

sketch

//Yoshi Torralva
//yrt@andrew.cmu.edu
//Section E
//Project—09—Portrait
var underlyingImage;

function preload() {
    var myImageURL = "https://i.imgur.com/htGpgok.jpg";
    underlyingImage = loadImage(myImageURL);
}

function setup() {
    createCanvas(480, 480);
    background(0);
    underlyingImage.loadPixels();
}

function draw() {
    //variables to randomize location
    var px = random(width);
    var py = random(height);
    var ix = constrain(floor(px), 0, width-1);
    var iy = constrain(floor(py), 0, height-1);
    var theColorAtLocationXY = underlyingImage.get(ix, iy);
    frameRate(360);

    //large border that indicates which pixel is drawn
    // rectangles redrawn at different angles that creates circular border
    push();
    rectMode(CENTER);
    translate(240, 240);
    noFill();
    stroke(theColorAtLocationXY);
    strokeWeight(1);
    rotate(random(0, 10));
    rect(10, 10, 460, 460);
    pop();

    //light beams formed by random length
    noStroke();
    fill(theColorAtLocationXY);
    //shorter beams for greater quality 
    rect(px, py, random(1), random(4, 50));
    //longer beams for greater expression 
    rect(px, py, random(1), random(50, 100));

    //placed on top layer to create a more visible image
    //end points of the beams
    push();
    rectMode(CENTER);
    rect(px, py, 3, 3);
    pop();
}

start of the portrait
in the middle of the generation of the portrait
nearing the end of the generative portrait
Self-portrait

With this project, I wanted to use an image that was simple which would allow me to have an increased focus on the formulation of forms. I decided to use this self-portrait photo from the mattress factory as it only relies on black and blue. I was inspired by light beams and achieved this through randomly sized length rectangles with squares placed on the top of each randomized length rectangle. To add an additional element, I placed a rotating square that formed a circular border informed by called pixel colors.

Caroline Song – Project 09 – Computational Portrait

sketch

//Caroline Song
//chsong@andrew.cmu.edu
//Section E
//Project 09

var imageUnderneath;
var imageColor;
var constrainX;
var constrainY;

function preload(){
    //preload image
    var myImageURL = "https://i.imgur.com/SHu7RYA.jpg";
    imageUnderneath = loadImage(myImageURL);
}

function setup(){
    createCanvas(450, 450);
    background(0);
    imageUnderneath.loadPixels();
    frameRate(1000);
}

function draw(){
    var rectX = random(width); //rectangles are placed randomly along width of canvas
    var rectY = random(height); //rectangles are placed randomly along height of canvas
    var rectSize = 10; //size of rectangle
    var ellipseSize = 10; //size of ellipse

    //constrain rectangles to canvas size
    constrainX = constrain(floor(rectX), 0, width);
    constrainY = constrain(floor(rectY), 0, height);
    
    //get and fill colors according to picture underneath
    imageColor = imageUnderneath.get(constrainX, constrainY);
    noStroke();
    fill(imageColor);

    //ellipses are drawn instead of rectangles when key 'e' is pressed
    if(key == 'e' || key == 'E'){
        ellipse(constrainX, constrainY, ellipseSize);
    } else{
        rect(constrainX, constrainY, rectSize, rectSize);
    }
}

This project was very interesting, however, I didn’t know how to approach it at first. I wanted to have some sort of interactive element to my self-portrait project. In my final piece, I chose to switch the shapes that the code draws in, from rectangles to ellipses.

Final project after 30 seconds
Final project after 3 min
Original picture

Kimberlyn Cho- Project 09- Portrait

ycho2-09


/*Kimberlyn Cho
ycho2@andrew.cmu.edu
Section C
Project 09 */

var underlyingImage;
//array of emoticons to choose from
var words = [";)", ":P", ">_<", "^.^", "<3"];
var expression = ["damnnn", "wow", "omg", "beautiful"]

function preload() {
    var myImageURL = "https://i.imgur.com/mZFEEAK.jpg";
    underlyingImage = loadImage(myImageURL);
};

function setup() {
    createCanvas(360, 480);
    background(0);
    underlyingImage.loadPixels();
    frameRate(10);
};

function draw() {
    var px = random(width);
    var py = random(height);
    var ix = constrain(floor(px), 0, width-1);
    var iy = constrain(floor(py), 0, height-1);
    var theColorAtLocationXY = underlyingImage.get(ix, iy);

    noStroke();
    fill(theColorAtLocationXY);
    //randomize emoticon choice
	var textchoice = floor(random(0, 5));
	//randomize emoticon size
	var sizechoice = floor(random(10, 20));
	textSize(sizechoice);
	//choosing from array of emoticons 
	text(words[textchoice], px, py);
};

function mousePressed() {
	//generating "damnnn" with mousePressed
	var theColorAtTheMouse = underlyingImage.get(mouseX, mouseY);
    fill(theColorAtTheMouse);
    var textchoice = floor(random(0, 4));
	var sizechoice = floor(random(10, 20));
	textSize(sizechoice);
    text(expression[textchoice], mouseX, mouseY);
};

I chose my best friend from home for this assignment because I miss her very much. I used cute emoticons to represent her lovable and adorable character. I randomized the size and emoticon choice to vary the process. Lastly, I generated my first reactions to seeing this photo with the mouse pressed function.

early development
progressed development
original photo

Xu Xu – Project 09 – Computational Portrait

sketch

//Claire Xu
//xux1@andrew.cmu.edu
//Section B
//Project-09
var cX = 250;
var cY = 250;
var vX = 3;
var vY = 5;

var currentImage;

function preload(){
	var myImage = "https://i.imgur.com/Bo3UtYO.jpg";
	currentImage = loadImage(myImage);

}

function setup(){
	createCanvas(500,500);
	background(0);
	currentImage.loadPixels();
	frameRate(50);
}

function draw(){
	var ix = constrain(floor(cX), 0, width);
	var iy = constrain(floor(cY), 0, height);
	var xyColor = currentImage.get(ix, iy);



	if(cX >= width || cX <= 0){
		vX = -vX;
	}

	if(cY >= height || cY <= 0){
		vY = -vY;
	}

	cX += vX;
	cY += vY;

	noStroke();
	fill(xyColor);
	circle(cX, cY, random(5,20));

	var xyColorMouse = currentImage.get(mouseX, mouseY);
	if(mouseIsPressed){
		noStroke();
		fill(xyColorMouse);
		circle(mouseX, mouseY, random(5,10));
	}
}

For this project I used the cosplay image of my friend, and I wanted the circles to appear in lines rather than random dots, so it looks like something is actually “printing” the image. The circles being printed tend to be larger, and the circles drawn by the mouse are smaller so more details of the photo can be observed manually.

Min Ji Kim Kim – Project 09 – Portrait


sketch

I decided to use a picture of my brother who I miss so much. I played around with a lot of shapes and sizes and I decided to use a water drop shape because my brother loves rain.

halfway done rendering

final stage in rendering

original image of my brother

/*
Min Ji Kim Kim 
Section A
mkimkim@andrew.cmu.edu
Project-09
*/

var originalImage;

function preload() {
    var myImageURL = "https://i.imgur.com/hKHw7ls.jpg";
    originalImage = loadImage(myImageURL); //load image
}

function setup() {
    createCanvas(384, 480);
    background(0);
    originalImage.loadPixels();
    frameRate(1000); //make waterdrops appear faster
}

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

    //make waterdrop shape
    var rectSize = random(3,10); //change waterdrop size
    noStroke();
    fill(locationColor);
    rect(px, py, rectSize, rectSize, 0, 5, 5, 5);
}

Mihika Bansal – Project 09 – Portrait

sketch

//Mihika Bansal 
//mbansal@andrew.cmu.edu 
//Section E 
//Project 9

var portrait; 

function preload(){
    var url = "https://i.imgur.com/rh2ehQc.jpg"; 
    portrait = loadImage(url); 
}

function setup() {
    createCanvas(480, 480);
    background(0);
    portrait.loadPixels(); 
    frameRate(2000); 
}
   
function draw() {
    //random pixel 
    var px = floor(random(width)); 
    var py = floor(random(height)); 

    //color variables for that pixel 
    var cx = constrain(px, 0, width - 1); 
    var cy = constrain(py, 0, height - 1); 

    var colorLoc = portrait.get(cx, cy); 

    noStroke(); 
    fill(colorLoc); 

    //person (rectangles)
    if(px > 120 & px < 430 && py > 30 && py < height){
        rect(px, py, 5, 5); 
    }
    //background (ellipses)
    else{
        ellipse(px, py, 10, 10); 
    }
    
}
  

This project was very interesting to complete. I enjoyed the process of playing with different shapes to complete the different colored sections that worked together to form the portrait. I wanted to use larger ellipses in the background to create a more hazy background.

Screenshot 1
Nearly final image
The original image

Charmaine Qiu – Project 09


sketch

Finished Portrait

When mouse is dragged on canvas

In this project, I had fun creating an interactive portrait of myself. I mimicked splashes of paint dropping down when the mouse is dragged on the canvas. I got to utilize what I learned from the previous assignments and incorporate them in my project.

//Charmaine Qiu
//charmaiq@andrew.cmu.edu
//Section E
//Project 09

var underlyingImage;
//create an empty array
var xarray = []
var yarray = []
//load the image from imgur.com
function preload() {
    var myImageURL = "https://i.imgur.com/cplu0CL.jpg";
    image = loadImage(myImageURL);
}

function setup() {
    createCanvas(400, 300);
    background(0);
    image.loadPixels();
    frameRate(100000000); //generate the image in a faster speed
}

function draw() {
    var px = random(width); //the location for x coordinate
    var py = random(height); //the location for y coordinate
    var ix = constrain(floor(px), 0, width-1); //constraining within the canvas
    var iy = constrain(floor(py), 0, height-1); //constraining within the canvas
    var theColorAtLocationXY = image.get(ix, iy);//fill in the color according to color of image
    noStroke();
    fill(theColorAtLocationXY);
    //draw the ellipses
    ellipse(px, py, 6, 6);
    //get the color of image at the mouse
    var theColorAtTheMouse = image.get(mouseX, mouseY);
    stroke(theColorAtTheMouse);
    //loop over the length of the array
    for (var i = 0; i < xarray.length; i ++){
        //fill with the color at the mouse
        fill(theColorAtTheMouse);
        ellipse(xarray[i], yarray[i], 5, 5);
        //make the ellipses go down mimicking paint drooling down
        yarray[i] += 0.5;
        }
  }
  //when mouse is dragged, add the mouse position to the array
function mouseDragged(){
    xarray.push(mouseX);
    yarray.push(mouseY);
  }

 //when mouse is pressed, a new array is created
function mousePressed(){
    xarray = [];
    yarray = [];
  }

Margot Gersing – Project 09

mgersing-09

//Margot Gersing - Project 09 - mgersing@andrew.cmu.edu - section E

var img; //original image
var sizeOne; //pixel size one
var sizeTwo; //pixel size two


function preload() {
    img = loadImage('https://i.imgur.com/Tx6sITJ.jpg?2'); //preload the image
}

function setup() {
    createCanvas(500, 761); //cnavas side of the image
    sizeOne = 1; //setting pixel size one to one
    sizeTwo = 20; //setting pixel size two to 20
    imageMode(CENTER);
    noStroke();
    background(255);
    img.loadPixels(); //pixelate the image
    frameRate(10000); //fast frame rate to load pixels faster

}

function draw() {
    //map the pixels size from 1 to 20, based on mouse postion
    var size = map(mouseY, 0, height, sizeOne, sizeTwo);
    var sizeW = map(mouseX, 0, width, sizeOne, sizeTwo);
    var x = floor(random(img.width));
    var y = floor(random(img.height));
    var pix = img.get(x, y);
    fill(pix, 128);
    ellipse(x, y, size, sizeW); //pixel is a ellipse based on the mapped size from mouse position
}

My grandmother, 11 or 12 (1940s)

For this project I decided to do a portrait of my grandmother when she was 11 or 12. I really like this photo of her and how it serves as a view into the past. It’s interesting to use such an old photo (1940s) in such a modern context and project.

I decided to have the pixels size dependent on the mouse position. This way you can control the way the image looks. The timing of when and where your mouse is also affects how the image will turn out.

variations on the image dependent on the mouse location and time.

Jasmine Lee – Project 09 – Portrait

compportrait

//Jasmine Lee
//jasmine4@andrew.cmu.edu
//Section C 
//Project-09 (Computational Portrait)

var baseImage;

function preload() {
    var myImageURL = "https://i.imgur.com/Iprm8zU.jpg";
    baseImage = loadImage(myImageURL);
}

function setup() {
    createCanvas(400, 523);
    background(255);
    baseImage.loadPixels();
    frameRate(10000000);
    grid();
}

//creates grid "cloth" in background
function grid() {
    //creates the vertical lines
    for (var gridA = 0; gridA < width; gridA += 10){
        noStroke();
        fill(255, 238, 186);
        rect(gridA, 0, 2, 523);
    }
    //creates the horizontal lines
    for (var gridB = 0; gridB < height; gridB += 10) {
        noStroke();
        fill(255, 238, 186);
        rect(0, gridB, 400, 2);
    }
}

function draw() {

    var px = random(width); //randomixes location of crosstitch
    var py = random(height); //randomizes location of crossstitch
    var la = random(0, 30); //used for randomizing length of line
    var lb = random(0, 20); //used for randomizing length of line
    var a = random(1,15); //used for randomizing width of beads
    var b = random(1,15); //used for randomizing height of beads
    var ix = constrain(floor(px), 0, width - 1); //randomizes color of crosstitch
    var iy = constrain(floor(py), 0, height - 1); //randomizes color of crosstitch
    var theColorAtLocationXY = baseImage.get(ix, iy);
    var theColorAtMouse = baseImage.get(mouseX, mouseY);

    //draw cross-stitches
    strokeWeight(1);
    stroke(theColorAtLocationXY);
    line(px, py, px + 10, py - 10);
    line(px, py - 10, px + 10, py);

    //draw lines
    strokeWeight(random(0.2, 2));
    stroke(theColorAtMouse);
    line((mouseX - la), (mouseY - lb), (mouseX + la), (mouseY + lb));

    //draw lines-glint
    stroke(0.1);
    stroke(255, 255, 255, 150);
    line ((mouseX - la), (mouseY - lb - 0.5), (mouseX + la), (mouseY + lb - 0.5));

    //draw beads
    noStroke();;
    fill(theColorAtMouse);
    ellipse(mouseX, mouseY, a, b);
 
    //draw bead-glint
    fill(255, 255, 255, 150);
    ellipse(mouseX + 2, mouseY - 2, a - (a - 2), b - (a - 2));
}

//clears canvas when mouse is clicked
function mousePressed() {
    clear();
    //redraws grid after clearing canvas
    grid();

}



For this project, I chose to use a cross-stitching motif. I was inspired by the embroidery theme so I also included shiny “beads” and “thread” that follow the mouse cursor, as if the viewer was stitching along with the program. The resulting image, with movement of the mouse, results in a fuzzy image reminiscent of a especially fuzzy sweater.

Sketch of the intended elements of the project.
The resulting images after 2 min, 5 min, and 5 min (with the mouse effects).
The original image used.