Created
November 19, 2016 16:20
-
-
Save xraymemory/6c16e7c8d72907baa9b54a6301b20d92 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 [] poem1 ={"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}; | |
| String [] poem ={"e", "x", "m", "a", "c", "h", "i", "n", "a", "c", "t", "r", "l", "o", "r", "g", "m", "o", "d", "e", "i", "c", "e", "n", "o", "x"}; | |
| String loadPath = "./sample.jpg" | |
| PImage picture; | |
| int devisions = 1; // pixels | |
| PFont font; | |
| float xDiv; | |
| float yDiv; | |
| void setup() { | |
| picture = loadImage(loadPath); | |
| size(780, 439); | |
| font = createFont("Kokoner", 1); | |
| xDiv = picture.width/devisions; | |
| yDiv = picture.height/devisions; | |
| } | |
| void draw() { | |
| background(255); | |
| textFont(font, devisions+3); | |
| for (int i = 0; i < height; i+= devisions) { | |
| for (int j = 0; j < width; j+= devisions) { | |
| color filler = picture.get(int(j), int(i)); | |
| fill(color(red(filler), green(filler), blue(filler))); | |
| //gets char depending on brightness | |
| float value = brightness(filler); | |
| String charac = poem[int(random(poem.length))]; | |
| text(charac, (j), (i)); | |
| } | |
| } | |
| } | |
| void keyPressed() { | |
| if (key == CODED) { | |
| if (keyCode == UP) { | |
| devisions++; | |
| } else if (keyCode == DOWN) { | |
| if (devisions > 0) { | |
| devisions--; | |
| }; | |
| } | |
| } | |
| if (key == 'e') { | |
| draw(); | |
| } | |
| constrain(devisions, 1, 99); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment