Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement