xxxxxxxxxx
//code credit: Manoylov AC http://manoylov.tumblr.com/ link to original code: https://www.openprocessing.org/sketch/158305
//the dense spiral of pixels isn't supposed to be there, it shows up normally in processing
float px, py, r, degree;
float minWeight = .8;
float maxWeight = 6;
float currWeight;
float spacing = maxWeight+.1;
float goldenRatio = ((sqrt(5) + 1 ) / 2);
int iter = 0, imgNum = (int)random(4);
boolean smallChaos = false;
PImage img;
//additional circles
int numCircs = 500;
float[] circX = new float[numCircs];
float[] circY = new float[numCircs];
float[] circD = new float[numCircs];
void setup() {
img = loadImage("jimin1.jpg");
size(600, 700);
background(9,19,35);
px = width/2;
py = height/2;
//additional circles-flashing stars
for (int i = 0; i<numCircs; i = i+1) {
circX[i] = random(width);
circY[i] = random(height);
circD[i] = random(0, 5);
}
spaceCircs ();
bgCirc();
}
void draw() {
faceGrid ();
spacing += 0.01;
//save("poster2.png");
}
void calcPointPos(float x, float y, float r, float graden) {
px = x + cos(radians(graden))*(r/2);
py = y + sin(radians(graden))*(r/2);
if (smallChaos) {
px = x + random(maxWeight)+ cos(radians(graden))*(r/2);
py = y + random(maxWeight)+ sin(radians(graden))*(r/2);
}
}
void faceGrid () {
// face
for (int i = 34; i > 0; --i) { // for more speed
degree = (iter * goldenRatio) * 360;
r = sqrt(iter++) * spacing;
calcPointPos(width/2, height/2, r, (degree % 360));
color pix = img.get((int)px, (int)py);
currWeight = map(brightness(pix), 255, 0, minWeight, maxWeight);
strokeWeight(currWeight);
stroke(250); // stroke(pix);
point(px, py);
if (px-10 <= 0 || px+10 >= width || py-10 <= 0 || py+10 >= height ) {
noLoop();
}
}
}
void spaceCircs () {
//flashing circles space
noStroke();
fill(random(255));
for (int i = 0; i<numCircs; i++) {
ellipse(circX[i], circY[i], circD[i], circD[i]);
}
}
void bgCirc () {
//circle to keep flashing circles from affecting the main picture
fill(9,19,35);
noStroke();
ellipse(width/2, height/2, 500, 500);
}