# svitoora – 08 Lines in the Dark

``````// Supawat Vitoorapakorn
// Svitoora@andrew.cmu.edu
// Section E

var face = "https://i.imgur.com/EyvV5mU.jpg"
var img;
var pixel_info = [];

// Createm Node
function new_pixel(x, y, k) {
this.x = x;
this.y = y;
this.m = map(k, 0, 255, 50, 1);
}

}

w = 480;
h = w;

function setup() {
createCanvas(w, h);
background(255 * .75);
image(img, 0, 0, w, h);

// Extract Image info
step = 1;
for (Y = 0; Y < w; Y += step) {
for (X = 0; X < h; X += step) {
k = brightness(get(X, Y));
// print(X, Y, k);
pixel_info.push(new new_pixel(X, Y, k));
step = random(7, 10)
}
}

// Sort pixels by brightness
pixel_info.sort(function(a, b) {
return a.k - b.k
});

// Print info and clear screen
print(pixel_info);
background(255 * .2);

// Draw
noStroke();
print(pixel_info.length)
draw_face(.9);
draw_face(.2);
}

// Draw Face
function draw_face(opacity) {
for (i in pixel_info) {
x = pixel_info[i].x;
y = pixel_info[i].y;
k = pixel_info[i].k;

r = map(k, 0, 255, 15, 1);

noStroke();
fill(k, k, k, 255 * opacity);
ellipse(x, y, r, r);
}
}

// Increase contrast
// x is input
// k is percent e.g. 0.1
if (x < 255 / 2) {
x = x * (1 + p);
} else {
x = x * (1 - p);
}
return x
}

for (i in pixel_info) {
x = pixel_info[i].x;
y = pixel_info[i].y;
k = pixel_info[i].k;
for (i in pixel_info) {
x1 = pixel_info[i].x;
y1 = pixel_info[i].y;
k1 = pixel_info[i].k;
if (round(k) == round(k1)) {
strokeWeight(1);
stroke(k, k, k, 255 * .05);
line(x, y, x1, y1);
}
}
}
}``````

## Portrait

I was experiencing some dark times in my life, therefore I decided to make a dark portrait. I was inspired by the algorithmic portrait.

I tried to replicate the portrait above, but sadly I couldn’t do in time. Since my portrait is a bit computationally heavy, here is a still image of it:

SaveSave

SaveSave