Created
September 11, 2014 04:30
-
-
Save xraymemory/a1884ca2ff30a09004ca 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
| PImage poemImg; | |
| PFont poemFont; | |
| String sourceText[]; | |
| String displayPoemText; | |
| int defaultXSlice = 4; | |
| int defaultYSlice = 6; | |
| int ySlice = defaultXSlice; | |
| int xSlice = defaultYSlice; | |
| int poemIndexer = 0; | |
| boolean firstRun = true; | |
| void setup() { | |
| background(51); | |
| poemImg = loadImage("mosiac.JPG"); | |
| poemFont = createFont("Futura", 10, true); | |
| //poemImg.resize(poemImg.width / 2, poemImg.height / 2); | |
| poemImg.loadPixels(); | |
| size(poemImg.width, poemImg.height); | |
| sourceText = loadStrings("divine.txt"); | |
| sourceText = trim(sourceText); | |
| } | |
| void draw() { | |
| textFont(poemFont); | |
| if (firstRun) { | |
| displayPoemText = buildPoem(poemImg, sourceText); | |
| firstRun = false; | |
| } | |
| for (int x = 0; x < poemImg.width; x = x + xSlice) { | |
| for (int y = 0; y < poemImg.height; y = y + ySlice) { | |
| fill(poemImg.get(x, y)); | |
| text(displayPoemText.charAt(poemIndexer), x, y); | |
| poemIndexer = poemIndexer + 1; | |
| } | |
| } | |
| noLoop(); | |
| } | |
| String buildPoem(PImage img, String srcText[]) { | |
| String poem = " "; | |
| for (int i = 0; i < srcText.length; i = i + 1) { | |
| poem = poem + srcText[i]; | |
| } | |
| return poem; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment