Last active
March 8, 2019 15:08
-
-
Save m0wh/de839dc50dd3d729640adcc9274ad0c9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PImage img; | |
color c; | |
PFont font; | |
int x,y; | |
int RESOLUTION[] = {720,180}; | |
PGraphics epg; | |
void sizing(PImage i) { | |
int r; | |
r = 10000*RESOLUTION[0]/i.width; | |
surface.setSize(r*i.width/10000, r*i.height/10000); | |
i.resize(r*i.width/10000, r*i.height/10000); | |
} | |
void setup() { | |
size(200,200); | |
font = loadFont(FONT_FAMILY); | |
img = loadImage(FILE_NAME); | |
sizing(img); | |
if (SEED == -1) { | |
SEED = round(random(999999999)); | |
} | |
randomSeed(SEED); | |
noLoop(); | |
} | |
void draw() { | |
sketch(this.g); | |
epg = createGraphics(round((width*0.96)*DPI/72), round((height*0.96)*DPI/72)); | |
epg.beginDraw(); | |
epg.scale(DPI/72); | |
sketch(epg); | |
if(FILE_PREFIX == "") { | |
if (CURVY) { | |
epg.save("generated/" + FILE_NAME + "/test-i" + ITER + "-a" + ANGLES + "-s" + SIZE + "-o" + OPACITY + "-" + SEED + "-curvy.png"); | |
} else { | |
epg.save("generated/" + FILE_NAME + "/test-i" + ITER + "-a" + ANGLES + "-s" + SIZE + "-o" + OPACITY + "-" + SEED + ".png"); | |
} | |
} else { | |
epg.save("generated/" + FILE_PREFIX + "-" + SEED + ".png"); | |
} | |
epg.endDraw(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String FILE_NAME = "image.jpg"; | |
int DPI = 300; // export DPI | |
String FILE_PREFIX = ""; // if string is empty, a default prefix based on the settings is used. | |
int ITER = 100000; | |
int ANGLES = 500; | |
int SIZE = 5; | |
int OPACITY = 200; | |
boolean CURVY = false; | |
boolean DRAW_SETTINGS = true; | |
color TEXT_COLOR = #ffffff; | |
int FONT_SIZE = 12; | |
String FONT_FAMILY = "firamono.vlw"; | |
int SEED = -1; // -1 will be random |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import processing.pdf.*; | |
void sketch(PGraphics pg) { | |
pg.noStroke(); | |
pg.background(0); | |
img.resize(int(width), int(height)); | |
pg.image(img, 0, 0); | |
for(int i = 0; i < ITER; i++) { | |
x = floor(random(img.width)); | |
y = floor(random(img.height)); | |
c = img.get(x,y); | |
pg.fill(c,OPACITY); | |
pg.beginShape(); | |
for(int a = 0; a < random(ANGLES); a++) { | |
x+=random(-SIZE,SIZE); | |
y+=random(-SIZE,SIZE); | |
if (CURVY) { | |
pg.curveVertex(x, y); | |
} else { | |
pg.vertex(x, y); | |
} | |
} | |
pg.endShape(CLOSE); | |
} | |
if (DRAW_SETTINGS) { | |
pg.fill(TEXT_COLOR); | |
pg.textFont(font); | |
pg.textSize(FONT_SIZE); | |
pg.textLeading(FONT_SIZE); | |
pg.textAlign(RIGHT, TOP); | |
if (CURVY) { | |
pg.text("iterations: " + ITER + "\nvertices: " + ANGLES + " curvy\nshapes size: " + SIZE + "\nshapes opacity: " + OPACITY + "\nseed: " + SEED, 10, 10, width-20, height-20); | |
} else { | |
pg.text("iterations: " + ITER + "\nvertices: " + ANGLES + "\nshapes size: " + SIZE + "\nshapes opacity: " + OPACITY + "\nseed: " + SEED, 10, 10, width-20, height-20); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment