Shannon Case- Project 09

For my project I chose to do a portrait of my roommate sticking her tongue out. I used triangles to represent her because this is her favorite shape and we both agreed that the aesthetic of this is better because its more varied than ellipses and rectangles or lines. As the project evolves it fills in to reveal the picture.  sketch

var underlyingImage;

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

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

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);
    var point2 = random(40);
    var point3 = random(60); //sets variables for the triangle points

    noStroke();
    fill(theColorAtLocationXY);
    triangle(px, py, px + point2, py + point2, px + point2/2, py +point3);
    //draws the image in varrying sizes of triangles


}

screen-shot-2016-10-28-at-7-47-18-pm

screen-shot-2016-10-28-at-7-47-25-pm

screen-shot-2016-10-28-at-7-47-09-pm

Simin Li – Project 9

screen-shot-2016-10-27-at-9-35-34-pmsiminl-project9inobjects

// Simin Li
// Section C
// siminl@andrew.cmu.edu
// Project 9 in objects
var d = 9;
//side length of each rhombus
var portrait;
//the image to be preloaded
var cubes = [];
//create array named cubes
var m = 0;
//index of the array cubes
var pointt = [];
//create an array to store coordinates not yet used 
var getIndex = 0;
//the index of the number of array[2]
for(var k = -45; k < 62; k++){
    for(var n = -45; n < 62; n++){  
        pointt.push([k,n]); 
    }
}
//create a 2D array called pointt and store arrays of length of 2 using a for loop in it
function preload(){
    portrait = loadImage("http://i.imgur.com/QPplgCrg.jpg");
    //load image
}
function setup() {
    createCanvas(600, 600);
    background(0);
    portrait.resize(610,610);
    //resize the original image to fit on a 800 by 800 canvas
    //when resized to 600 by 600 rgb values of border points are undefined
    //so it is resized to 610 by 610
    portrait.loadPixels();
    //load pixels
    frameRate(100);
    
}

function draw() {
 
    colorMode(RGB);
var gapY = d * sqrt(3) / 2;
//differnce of x values between two adjacent hexagon left corners
var gapX = d *  3 / 2;
//differnce of y values between two adjacent hexagon left corners     

IndexofCoordinate = floor(random(0,pointt.length));
//randomly select an array inside the array pointt 
var j = pointt[IndexofCoordinate][0];
//j is the first element of the selected array
//assign a random value to j so it draws in a random hexagon slot
var i = pointt[IndexofCoordinate][1];  
//i is the second element of the selected array
//assign a random value to i so it draws in a random hexagon slot  
var X = 18 + gapX * j;
var Y = gapY * j;

    cubeX = X + gapX * i;
    //x coordinates of hexagon
    cubeY = Y - gapY * i;
    //y coordinates of hexagon
    color1 = portrait.get(cubeX + d , cubeY + 3);
    //color of bottom left rhombus is determined by a pixel in that rhombus
    color2 = portrait.get(cubeX + d , cubeY - 3);
    //color of top left rhombus is determined by a pixel in that rhombus
    color3 = portrait.get(cubeX + d + 3, cubeY);
    //color of right rhombus is determined by a pixel in that rhombus
    cubes[m] = new Cube(cubeX,cubeY,color1,color2,color3);
    cubes[m].draw();
    m ++;
    pointt.splice(IndexofCoordinate, 1);
    //remove the coodinate that has already been used so it doesn't redraw in the same slot
    println(IndexofCoordinate);
}

function rhombus(x,y,angle){
//create function that draws rhombus at x,y
//rotate by angle
    var h = d * sqrt(3)/2;
    //height of rhombus
    push();
        translate(x, y);
        rotate(radians(angle));
        shearX(radians(30));
        //shifts a rectangle into a parallelogram by 30 degrees
        rect(0, 0, d, h);
    pop();
}
function Cube(x,y,color1,color2,color3){
//creates object that combines three rhombuses into a cube at x,y
//each filled by color1,color2,color3
    this.x = x;
    this.y = y;
    this.color1 = color1;
    this.color2 = color2;
    this.color3 = color3;

this.draw = function(){
	noStroke();
	fill(color1);
    rhombus(x,y,0);//draws bottom left rhombus
    
    fill(color2);
    rhombus(x,y,300);//draws top left rhombus
    push();
        translate(1.50 * d, d * sqrt(3)/2);
        fill(color3);
        rhombus(x,y,240);//draws right rhombus
    pop();
    }
}

  I wanted controlled randomness in my portrait because I don’t like overlapping geometric shapes so I decided to use my wallpaper project as a template and treated the tiles as “slots” I could fill in randomly. I wanted to practice my objects so in the end I organized my code using an object. After I finished, I realized that a lot of spots were being reused so it is takes a long time to fill in the last few slots. So with help, I decided to create a 2d array that stored all of the coordinates that have not been used yet. After I drew that cube I removed it from the array.

file_000

Kyle Lee Project 09

For my self portrait, I randomly spread particles across the canvas, and set each fill color to its corresponding location and color on the original image. I then cascaded each to move in random directions, creating streaks of color that distort the image the longer the code runs.

 

kdlee-09

var underImage;
var x = [];
var y = [];
var dx = [];//movement
var dy = [];//movement
var col = [];//color
var d = [];//diameter
var movement = .5;//speed of particles
var particles = 3000;//number of particles
var diameterS = 1;
var diameterL = 10;

function preload() {
    var url = "http://i.imgur.com/S9K9aFe.jpg";
    underImage = loadImage(url);
}

function setup() {
    createCanvas(400, 600);
    background(250);
    underImage.loadPixels();
    frameRate(30);
    noStroke();

    for (i = 0; i < particles; i++) { // for creating 2000 elements
        x[i] = random(width);
        y[i] = random(height);
        dx[i] = random(-movement, movement);
        dy[i] = random(-movement, movement);
        d[i] = random(diameterS, diameterL);
        col[i] = underImage.get(x[i], y[i]);//pulls color from coordinate
    }
}

function draw() {
    for (i = 0; i < particles; i++) {  // for drawing 2000 elements
        fill(col[i]);
        ellipse(x[i], y[i], d[i], d[i]);
        x[i] += dx[i]//builds movement
        y[i] += dy[i]//builds movement
        if (x[i] > width) x[i] = 0;        // wrap horizontally
        else if (x[i] < 0) x[i] = width;
        if (y[i] > height) y[i] = 0;       // wrap vertically
        else if (y[i] < 0) y[i] = height;
    }
}

Project 09 – Alison Hoffman

For this project I used an old photo of my roommate Julia. I would like to think this is Julia in her prime. I wanted to recreate the photo with an object that was also representative of the photo- that is why I decided to make this picture of my little star out of little stars. While accidental, I like how the stars in end give the picture a distressed look especially since this is an older photo.

Original:

juliaedited

Half-way:

screen-shot-2016-10-28-at-11-30-25-am

Final result:

screen-shot-2016-10-28-at-7-22-01-pm

sketch

//Alison Hoffman
//Section D
//achoffma@andrew.cmu.edu
//Project 9

var imgJulz;
var starSize;

function preload() {
    var myImageURL = "http://i.imgur.com/RhNrs1N.jpg";
    imgJulz = loadImage(myImageURL);
}

function setup() {
    createCanvas(487, 867);
    background(0);
    imgJulz.loadPixels();
    frameRate(100);
}

function makeStar(radSize) {
  var angle = TWO_PI/5;
  var x = 0;
  var y = 0;
  beginShape(); // I referenced p5js.org to learn how to draw a star
  for (var i = 0; i < TWO_PI; i += angle) { //this is a simplified version of their practice code
    var sx = x + cos(i) * radSize;
    var sy = y + sin(i) * radSize;
    vertex(sx, sy);  //makes point at sx,sy
    sx = x + cos(i+(angle/2) * radSize);
    sy = y + sin(i+(angle/2) * radSize);
    vertex(sx, sy);
  }
  endShape(CLOSE);
}

function draw() {
    var px = random(width); //pixel x val
    var py = random(height); //pixel y val 
    var ix = constrain(floor(px), 0, width-1);
    var iy = constrain(floor(py), 0, height-1);
    var locXYcolor = imgJulz.get(ix, iy); //gets color of pixel

    starSize = 5; 

    noStroke();
    fill(locXYcolor);
    push();
    translate(px,py); //moves star to the pixel location 
    rotate(frameCount/ 50); // makes stars in different directions
    makeStar(starSize);
    pop();

}

Sarita Chen – Project 9 – Portrait

sketch

var img;
var pixelSize = 5;
var pixelX;
var pixelY;
function preload(){
	img = loadImage("http://i.imgur.com/oTBE2k6.jpg");
	img.width = 600;
	img.height = 600;
	frameRate(200);

}

function setup() {
    createCanvas(600, 600);
    background(0);
    imageMode(CENTER);
    img.resize(600,600);
    img.loadPixels();

}

function draw() {

	noStroke();
	pixelX = floor(random(width));
	pixelY = floor(random(height));
	var pixelGET = img.get(pixelX,pixelY);

	fill(pixelGET,100);
	rect(pixelX,pixelY,5,5);


}

I used a photo of me, my twin sister and my younger brother from when we were younger. Here are some progress images:

screen-shot-2016-10-27-at-7-26-22-pm    screen-shot-2016-10-28-at-5-03-56-pm

Here is the final thing (or close to the final, there are still some gaps here and there):

screen-shot-2016-10-28-at-6-19-54-pm

 

 

Michal Luria – 09 – Portrait

mluria-09

/*  Submitted by: Michal Luria
    Section A: 9:00AM - 10:20AM
    mluria@andrew.cmu.edu
    Assignment-09-Project
*/

var originalImage;

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

function setup() {
    createCanvas(500, 500); 
    background(0);
    originalImage.loadPixels(); //load pixels
    frameRate(20000);
}

function draw() {

    for (var i = 0; i < 500; i ++){ //draw 500 pixels each frame

        var px = random(width); //draw a line in a random x
        var py = random(height); //draw a line in a random y
        var ix = constrain(floor(px), -20, width-1); //constrain x
        var iy = constrain(floor(py), -20, height-1); //contrain y
        var theColorAtLocationXY = originalImage.get(ix, iy); //what is the color at a specific location

        var curveX1 = random(1,15); //start of curve (X)
        var curveX2 = curveX1 + random(1,15); //second point - same direction(X)
        var curveX3 = curveX2 + random(1,15); //third point - same direction (X)

        var curveY1 = random(1,15); //start of curve (Y)
        var curveY2 = curveY1 + random(1,15); //second point - same direction(Y)
        var curveY3 = curveY2 + random(1,15); //third point - same direcation(Y)

        var strokeSize = random(1,3); //stroke weight random

        strokeWeight(strokeSize);
        stroke(theColorAtLocationXY); //stroke in the color of pixel

        curve(px, py, px+curveX1, py+curveY1, px+curveX2, py+curveY2, px+curveX3, py+curveY3); //draw curve

    }

}

In this portrait I wanted to create a feeling of a drawn portrait. To do this, I created random sized curves, in different angles, but all drawn to the same direction to create an artistic style. This is inspired by artists in the impressionist movement. The different sized curves create a sense of brushstrokes, and end up in an image that is not completely clear, but gives a sense of the portrait mood.

LookingOutwards-09-sehenry

The post that I thought had an interesting yet simple concept was found in Vtavarez‘s week 4 post. He wrote about how an artist made a graphical representation of a musical composition called He’s a Pirate. I listened to the soundtrack and it was the one from Pirates of the Caribbean. If you click on the link, then you can see that the The Wrong Way to Draw a Pirate is a animation of how the song comes to be. In the past LookingOutwards, I loved when we analyzed the relationship between sound and animation and this is just another example of how cool these things can be when they are illustrated clearly. The person who made this composition has made a series called The Wrong Way to Draw Music. On there, they have many different types of songs that are portrayed the same way as the Pirate song was. I do agree that the way that the song is drawn, could have been better. All the layers that were written before hand just get layered over by new sounds and pitches. However, I still think it was a really cool idea.

Grace Cha – Project 09- Portrait

sketc

//Grace Cha
//Section C
//heajinc
//Project 9 

var underlyingImage;

function preload() {
    var myImageURL = "http://i.imgur.com/ntVrOBL.jpg?1";
    underlyingImage = loadImage(myImageURL);
}

function setup() {
    createCanvas(400, 410);
    background(252);
    underlyingImage.loadPixels();


    vertX = random(0, width); //Picks a point randomly on top
    vertY = 0; //at the top
    horizX = 0; //Starts randomly
    horizY = random(0, height);//at the left side
    
}

function draw() {

    verticalGrace();
    horizontalC();
}
function verticalGrace() {
  var ix = constrain(floor(vertX), 0, width + 100); //set max and min of ix
  var iy = constrain(floor(vertY), 0, height + 100); //set max and min of iy
  var theColorAtLocationXY = underlyingImage.get(ix, iy); //Obtains pixel


  fill(theColorAtLocationXY); //Fill with pixel color at ix, iy
  
  textSize(10);
  
  
  noStroke();
  text("CHA", vertX, vertY); 
  
  vertY += 10; // move at a rate of 10 
  
  	if (vertY > height) { //If the GRACE hit bottom of canvas
  		vertY = 0; 	//resets the image back to the top
  		vertX = random(0, width ); //Relocate the x-coordinate of the rect
  	}
}

function horizontalC() {
    var ix = constrain(floor(vertX), 0, width-1); //set max and min of ix
    var iy = constrain(floor(vertY), 0, height-1); //set max and min of iy
    var theColorAtLocationXY = underlyingImage.get(ix, iy); //Obtains pixel

  
    fill(theColorAtLocationXY); 
    textSize(10);
    textStyle(BOLD);
    text("C",horizX, horizY ); 
  
    horizX += 10;
    if (horizX > width) {
  	    horizX = 0;
  	    horizY = random(0, height);
  	}	   
}


I played around with the idea of spelling my name out to display my face.  I tried using “GRACE” but the word was too long that it distorted the image, so I used my last name “CHA”.  To add contrast to the longer word “CHA” I decided to use one letter “C” to represent the horizontal rows.

Isabella Hong – Project – 09

ijhong-09p

// Isabella Hong
// Section A
// ijhong@andrew.cmu.edu
// Project 09


var img; 

function preload() {
	//my image 
	var imgURL = "https://i.imgur.com/hdA7L6z.jpg";
	img = loadImage(imgURL); 
}

function setup() { 
	//create canvas and load image on to it 
	createCanvas(525, 375);
	img.resize(525, 375); 
	background(255); 
	//rate at which pixels appear  
	frameRate(500);  
	img.loadPixels(); 
}

function draw() {
	//randomize the x and y coordinates 
	var CpixelW = random(width); 
	var CpixelH = random(height); 
	//keep pixels within the canvas 
	var CpositionX = constrain(floor(CpixelW), 0, width - 20); 
	var CpositionY = constrain(floor(CpixelH), 0, height - 20); 
	//get colors from the image 
	var colorxy = img.get(CpositionX, CpositionY);

	//draw the rectangular pixels and have them fill in the colors
	//from the original image 
	noStroke();  
	fill(colorxy);  
	rectMode(CENTER); 
	rect(CpixelW, CpixelH, 10, 10); 
}




	

For my portrait, I chose a photo of myself that my friend took while we were hiking at Ohiopyle. I liked that the photo had several different colors and depths, which I thought would add to the pixelated version. This is my project at various stages.

Stage 1

screen-shot-2016-10-28-at-1-17-22-pm

Stage 2

stage 2

Stage 3

screen-shot-2016-10-28-at-1-13-40-pm

Jinhee Lee; Project-09

jinheel1_project-09

//Jinhee Lee
//Section C
//jinheel1@andrew.cmu.edu
//Project-09

var underlyingImage;

function preload() {
    var myImageURL = "http://i.imgur.com/EH0p0KK.png";
    underlyingImage = loadImage(myImageURL);
}

function setup() {
    createCanvas(600, 600);
    background(70); //dark grey background to contrast with black
    underlyingImage.loadPixels();
    frameRate(25); //fast frame rate to fill up canvas
}

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

    var pixelSize = 10; //size of pixels spawning 

    var bright = brightness(theColorAtLocationXY); //extract brightness of pixel for greyscale effect
    var amt = map(bright, 0, 100, 0, 255); //map from 0 to 255 so overall image isn't too dark

    noStroke();
    fill(amt); //fills pixel with appropriate brightness value
    ellipse(px, py, pixelSize, pixelSize);
}

function mouseDragged() { //draws a line with mouse
    var theColorAtTheMouse = underlyingImage.get(mouseX, mouseY);
    stroke(theColorAtTheMouse); //while pixels are greyscaled, the line is colored
    strokeWeight(10); //thicker stroke so it can be seen

    line(pmouseX, pmouseY, mouseX, mouseY);
}

I made the generated pixels with a greyscale effect, along with a mouseDragged() function that adds color depending on the stroke of the mouse. Like breathing life into the photo, though if left alone too long, it would revert back to grey with the refreshing pixels.