Crystal-Xue-Project-09

sketch-231.js

//Crystal Xue
//15104-section B
//luyaox@andrew.cmu.edu
//Project-09

var underlyingImage;
var xarray = [];
var yarray = [];

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

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

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);

    stroke(theColorAtLocationXY);
    strokeWeight(random(1,5));
    var size1 = random(5,15);
    //brush strokes from bottom left to top right diagnal direction
    line(px, py, px - size1, py + size1);

    var theColorAtTheMouse = underlyingImage.get(mouseX, mouseY);
    var size2 = random(1,8);
    for (var i = 0; i < xarray.length; i++) {
        stroke(theColorAtTheMouse);
        strokeWeight(random(1,5));
        //an array of brush strokes from top left to bottom right diagnal direction controlled by mouse
        line(xarray[i], yarray[i],xarray[i]-size2,yarray[i]-size2);
        size2 = size2 + 1;
        if (i > 10) {
            xarray.shift();
            yarray.shift();
        }
    }
}

function mouseMoved(){
    xarray.push(mouseX);
    yarray.push(mouseY);
}

phase-1
phase-2
phase-3
original picture

This is a weaving portrait of my friend Fallon. The color pixels will be concentrated on the cross between strokes of two directions

CJ Walsh – Project 09

sketch

// CJ Walsh 
// Section D
// cjwalsh@andrew.cmu.edu
// Project 09

var baseI;
// loading the image into my code
function preload() {
    var myImageURL = "https://i.imgur.com/ItvWF6f.jpg";
    baseI = loadImage(myImageURL);
}
function setup() {
	createCanvas(360, 480);
 	background(0);
    baseI.loadPixels();
    frameRate(15); // speed at which the pixels appear
}

function draw() {
	// setting up conditions for pixels to appear
    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 baseColor = baseI.get(ix, iy);
    // drawing ellipses and rectangles to respresent the pixels of the image 
    noStroke();
    fill(baseColor);
    ellipse(px, py, random(0, 15), random(0, 15));
    rect(px, py, random(0, 15), random(0, 15));

}

While this was a pretty simple and straightforward project, it was fun to experiment with the different ways to present the color of the image through other shapes and forms. Ultimately I decided to go with both rectangles and ellipses because I liked the combination of the curved and angular forms in the images by code created. It was interesting to see the image build itself and lead up to looking closer to the base image. Overall, a fun project!

ilona altman – project 09

sketch

var theImage;

function preload() {
    //loading my image
    var myImageURL = "https://i.imgur.com/3SFfZCZ.jpg";
    theImage = loadImage(myImageURL);
}

function setup() {
    createCanvas(480, 480);
    background(250,250,250);
    theImage.loadPixels();

    // going through each pixel 
    for (x = 0; x < width+10; x = x+3) {
        for (y = 0; y < height+10; y = y+2) {
            var pixelColorXY = theImage.get(x, y);
            if (brightness(pixelColorXY) >= 0 & brightness(pixelColorXY) <= 20) {
                //light pink
                stroke(255,230,230,70);
                line(x, y, x-1,y-1);
            } else if (brightness(pixelColorXY) >= 20 & brightness(pixelColorXY) <= 50) {
                //orange
                stroke(250,170,160);
                line(x, y, x+3, y+3);
            } else if (brightness(pixelColorXY) >= 50 & brightness(pixelColorXY) <= 55) {
                //pink
                stroke(230,130,160);
                line(x, y, x+3, y+3);
            } else if (brightness(pixelColorXY) >= 55 & brightness(pixelColorXY) <= 60) {
                // light green
                stroke(180,195,200);
                line(x, y, x-1,y-1);
            } else if (brightness(pixelColorXY) >= 65 & brightness(pixelColorXY) <= 70) {
                //yellow orange
                stroke(235,180, 100);
                line(x, y, x-2, y-2);
            } else if (brightness(pixelColorXY) >= 75 & brightness(pixelColorXY) <= 85) {
                //blue
                stroke(196,130,130);
                line(x, y, x-1, y-1);
            } else if (brightness(pixelColorXY) >= 85 & brightness(pixelColorXY) <= 95) {
                //dark red
                stroke(220,80,80);
                line(x, y, x-1, y-1);
            } else if (brightness(pixelColorXY) >= 95 & brightness(pixelColorXY) <= 110){
                //pink
                stroke(220,69,90);
                line(x, y, x+2, y+2); 
            } else if(brightness(pixelColorXY) >= 110 & brightness(pixelColorXY) <= 130){
                //medium blue
                stroke(80,130,60);
                line(x, y, x+1, y+1); 
            } else if (brightness(pixelColorXY) >= 130 & brightness(pixelColorXY) <= 160){
                //light orange
                stroke(220,170,130);
                line(x, y, x+1, y+1);
            } else if (brightness(pixelColorXY) >= 130 & brightness(pixelColorXY) <= 160){
                //light orange
                stroke(202,70, 100);
                line(x, y, x+1, y+1);
            } else if (brightness(pixelColorXY) >= 160 & brightness(pixelColorXY) <= 190){
                //white
                stroke(255,255, 255);
                line(x, y, x+3, y+3);
            } else if (brightness(pixelColorXY) >= 190 & brightness(pixelColorXY) <= 220){
                //yellow
                stroke(150,130, 90);
                line(x, y, x+3, y+3);
            } else if (brightness(pixelColorXY) >= 220 & brightness(pixelColorXY) <= 255){
                //yellow
                stroke(200,60,60);
                line(x, y, x+3, y+3);

            }
         
         }   
    }

}
function draw() {

}

In this project, I was thinking about memories with my family and about my grandma. I took some photos this summer of her teaching the rest of my family how to make Lithuanian dumplings. In my psychology class it is interesting because we have been learning about how distortion happens to what we remember over time. This is why I chose to make my image a bit distorted, and not so clear. I also love gradient maps, and wanted to emulate this with this piece. Yellow, green and red are the colors of the Lithuanian flag as well.

Jacky Tian’s Project 09

sketch

//Project-09
//Yinjie Tian
//yinjiet@andrew.cmu.edu
//Section D
var protrait;

function preload() {
    protrait = loadImage("https://i.imgur.com/tOfQhhw.jpg");
}

function setup() {
    createCanvas(400, 450);
    background(0);
    protrait.loadPixels();
    frameRate(100);
}

function draw() { 
    var x = random(width);
    var y = random(height);
    var pix = protrait.get(x, y);

    stroke(pix);
    var lengthmap = constrain(map(15, 0, y, 0, 20), 5, 50);
    var weightmap = constrain(map(3, 0, 10, 0, x), 0.1, 3);

    push();
    strokeWeight(weightmap);
    line(x + random(-10, 10), y + random(-10, 10), x + lengthmap, y + lengthmap);   
    pop();

   
}

I played with random stroke length and weight to create this portrait I chose.

Timothy Liu — Project 09 — Portrait

I am using 1 grace day on this project.

tcliu-openended-09

// Timothy Liu
// 15-104, Section C
// tcliu@andrew.cmu.edu
// OpenEnded-09

var Eileen; // variable name of the person in my project!

function preload() {
    Eileen = loadImage("https://i.imgur.com/V7NYz2M.jpg"); // preloading the image
}

function setup() {
    createCanvas(300, 450);
    background(255);
    Eileen.loadPixels();
    frameRate(250);
    Eileen.resize(300, 450);
}

function draw() {

    // variables to determine the location of each hamburger
    var burgerX = random(width);
    var burgerY = random(height);

    // variables that ensure the hamburger drawn remains on the canvas
    var burgerOnCanvasX = constrain(floor(burgerX), 0, width - 1);
    var burgerOnCanvasY = constrain(floor(burgerY), 0, height - 1);

    // variables to determine the proportions and shape of each burger
    var burgerW = random(8, 14);
    var burgerH = random(6, 10);
    var meatWStart = burgerW / 2 - burgerW * 0.125;
    var meatW = burgerW * 0.75;
    var meatH = random(2, 4);

    // variable that identifies the pixel color of the underlying images
    var pixelColor = Eileen.get(burgerOnCanvasX, burgerOnCanvasY);

    // applies the pixel color to each hamburger in the foreground
    noStroke();
    fill(pixelColor); 

    // drawing each individual hamburger
    arc(burgerX, burgerY, burgerW, burgerH, PI, TWO_PI);
    rect(burgerX - meatWStart, burgerY, meatW, meatH);
    arc(burgerX, burgerY + meatH, burgerW, burgerH, 0, PI);

}

For this project, I used a photo I took of my girlfriend Eileen at In-n-out burger in California. I really liked the photo because it has a lot of vibrant colors (red, green, yellow, etc) which I thought would be fun to portray through abstract shapes and pixels. I decided to make each building block of the portrait shaped like a hamburger as a reference to the burgers in the foreground of the picture and the restaurant the photo was taken at. Each burger is proportionally built based on a random bun height and width, which means that each burger is a different, randomly generated size. Together, each of the burgers collects to form a portrait!

The early stages of hamburgers…
As more hamburgers are drawn, the color and shape begins to show…
A more complete version of my piece when more of the hamburgers have been drawn. The hamburgers aren’t super small, so it’s hard to depict the fine details, but the shape and figure are definitely there!
The original photograph!

Danny Cho – Project 9


Sketch

I made a self portrait generator that recognizes and connects bright red spots in an image and emphasizes / connects them. I also tried to imitate the characteristic of water color by playing with the transparency of ellipses being drawn.

This is the original image

This is what has been generated by the algorithm

//Danny Cho
//Project 9
//changjuc@andrew.cmu.edu
//section A

var underlyingImage;
var pixColor;
var squareColor;

//arrays for red spots' coordinates
var redSpotsX = [];
var redSpotsY = [];

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

//sets up the canvas
function setup() {
    createCanvas(750, 1334);
    background(0);
    underlyingImage.loadPixels();
    frameRate(1000);
}

function draw() {
    //random pixels chosen
    var px = random(width);
    var py = random(height);
    //limiting the randomness to be integers within the canvas boundary
    var ix = constrain(floor(px), 0, width-1);
    var iy = constrain(floor(py), 0, height-1);
    //color at the location
    var theColorAtLocationXY = underlyingImage.get(ix, iy);
    pixColor = color(theColorAtLocationXY);

    //if red value is the highest number out of RGB palette,
    //and is higher than 230, the part becomes pure red
    //and saves the coordinates of them for the lines to be drawn
    if (Math.max(red(pixColor), green(pixColor), blue(pixColor)) == red(pixColor)
        & red(pixColor) > 230) {
        redSpotsX.push(ix);
        redSpotsY.push(iy);
        
        pixColor = color(255, 0, 0);
    }
    //connects the red spots with lines
    for (var i = 0; i < redSpotsX.length - 1; i++) {
            stroke(200, 0, 0);
            strokeWeight(.1);
            line(redSpotsX[i], redSpotsY[i],
                 redSpotsX[i + 1], redSpotsY[i + 1]);
        }

    noStroke();
    // changes the transparency of the ellipses
    pixColor.setAlpha(100);
    fill(pixColor);
    ellipse(px, py, 15, 15);

}

Minjae Jeong-project09

sketch

//Minjae Jeong
//Section B
//minjaej@andrew.cmu.edu
//Project-9


var underlyingImage;

function preload() {
    var myImageURL = "https://i.imgur.com/4WraCGa.jpg";
    underlyingImage = loadImage(myImageURL);
    underlyingImage.resize(480,480);
}

function setup() {
    createCanvas(480, 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);
    var size = random(10, 30); //random from 1-10
    ellipse(px, py, size, size); //draw circles!

    var theColorAtTheMouse = underlyingImage.get(mouseX, mouseY);
    stroke(theColorAtTheMouse);
    textSize = random(10, 30);
    text("SQUARE", mouseX, mouseY); //draw "squares"
}

For this project, I used a photo of my roommate. One issue I could not solve was to adjust the size of the picture according to the canvas size, which is currently 3024 x 4032. Because of it, I do not think canvas is showing the whole image properly, which is why there are so many browns on canvas.

Fallon Creech-Project-09-Portrait

sketch

//Fallon Creech
//Section B
//fcreech@andrew.cmu.edu
//Project-09

var underlyingImage;

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

function setup() {
    createCanvas(500, 500);
    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);
    textStyle(NORMAL);
    textSize(random(15, 25));
    text("sketch", px, py);

    var theColorAtTheMouse = underlyingImage.get(mouseX, mouseY);
    stroke(theColorAtTheMouse);
    textStyle(BOLDITALIC);
    textSize(random(25, 35));
    text("doodle", pmouseX, pmouseY);
}

For this project, I used a picture of a friend sketching in her sketchbook. I decided to differentiate between interactions of the animation by using different text styles and words; the animation randomly generates the word “sketch,” but the word “doodle” appears at the mouse’s location, giving the animation some visual complexity. 

after 30 seconds
after 2 minutes
original image

Stefanie Suk – Project 09 – Portrait

sketch

//Stefanie Suk
//15-104 D
//ssuk@andrew.cmu.edu
//Project 09 - Portrait

var self;
var size;

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

function setup() {
  createCanvas(400, 600);
  size = 6; //size of heart
  noStroke();
  background(20); //background color before image shows
  imageMode(CENTER);
  self.loadPixels(); //loading pixels
  frameRate(30); //how fast heart covers canvas
  
}

function draw() {
    var x = random(self.width);
    var y = random(self.height);
    var pixie = map(0, 0, width, size, size);
    var p = self.get(x, y); //variables to create heart
    fill(p);
    ellipse(x+5, y-5, pixie, pixie);
    ellipse(x, y, pixie, pixie);
    ellipse(x-5, y-5, pixie, pixie);
    ellipse(x-10, y-10, pixie, pixie);
    ellipse(x+10, y-10, pixie, pixie);
    ellipse(x+2.5, y-2.5, pixie, pixie);
    ellipse(x-2.5, y-2.5, pixie, pixie);
    ellipse(x+7.5, y-7.5, pixie, pixie);
    ellipse(x-7.5, y-7.5, pixie, pixie);
    ellipse(x+7.5, y-12.5, pixie, pixie);
    ellipse(x-7.5, y-12.5, pixie, pixie);
    ellipse(x+5, y-15, pixie, pixie);
    ellipse(x-5, y-15, pixie, pixie);
    ellipse(x+2.5, y-12.5, pixie, pixie);
    ellipse(x-2.5, y-12.5, pixie, pixie);
    ellipse(x, y-10, pixie, pixie); //coordinates to create heart
}

I created hearts to cover up the canvas and show an image of me in Lawrenceville. I tried to show how much fun I had in Lawrenceville by filling up the canvas with hearts, and the bright colors of the image fits well with the hearts as well. 

original photo

Project-09-Portrait

After looking through all the examples and code offered on the website, I decided I wanted to experiment with a number of designs. I decided I would do this by dividing up my screen and designating a type of design/pattern for each section. I was originally going to divide it up equally into three parts, but then I experimented a bit and decided to make it more interesting than that. I first decided to bring attention to my eyes by having the section over them be in HSB color value. Then I had there be two sections like this, one vertical and one horizontal, overlapping on one of my eyes, creating a cross section. This divided up the screen, and I filled up the sections this cross created with different patterns.

sketch

var myImage;
var topOfEyes = 100;//general height of where the top of my eyes are
var bottomOfEyes = 160;//general height of where the bottom of my eyes are
var leftOfEye = 260;//general left of where the left of my right eye is
var rightOfEye = 320;//general right of where the right of my right eye is

function preload() {
    var imgURL = "https://i.imgur.com/P9ng7Hd.jpg";
    myImage = loadImage(imgURL);//loads image
}

function setup() {
    createCanvas(480, 480);
    background(0);
    myImage.loadPixels();//loads pixels from image
    frameRate(1000);//faster framerate
}

function draw() {
    myImage.resize(620,480);//resizes image so my face fits onscreen
    var pixlX = random(width);//random pixel from width values
    var pixlY = random(height);//random pixel from height values
    var constrX = constrain(floor(pixlX), 0, width - 1);//constrains x value 
    //and keeps it at whole number
    var constrY = constrain(floor(pixlY), 0, height - 1);//constrains y value 
    //and keeps it at whole number
    var colorFromXY = myImage.get(constrX, constrY);//constrains color to image
    noStroke();

    push();
    colorMode(HSB,100);//changes color value to HSB
    fill(colorFromXY);//takes color from photo "below" it
    //ribbons
    ellipse(pixlX, random(topOfEyes,bottomOfEyes), 3, 3);//verticle red line
    ellipse(random(leftOfEye,rightOfEye),pixlY, 3, 3);//horizontal red line
    pop();

    fill(colorFromXY);//takes color from photo "below" it
    ellipse(pixlX,pixlY, 5, 5);//puts circles of portrait across screen
    //gradation of rectanbgles that slowly increases from 320 to width
    rect(random(rightOfEye,rightOfEye + 32),pixlY, .5,.5);
    rect(random(rightOfEye + 32,rightOfEye + (32 * 2)),pixlY, 1,1);
    rect(random(rightOfEye + (32 * 2),rightOfEye + (32 * 3)),pixlY, 1.5,1.5);
    rect(random(rightOfEye + (32 * 3),rightOfEye + (32 * 4)),pixlY, 2,2);
    rect(random(rightOfEye + (32 * 4),rightOfEye + (32 * 5)),pixlY, 2.5,2.5);
}

Portrait In Process
Final Product