Advertisement
xeromino

scanned.animals

Oct 15th, 2015
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.32 KB | None | 0 0
  1. import com.hamoid.*;
  2.  
  3. VideoExport videoExport;
  4. XML root, channel, item, description, title;
  5. XML[] items;
  6. String[][] sources;
  7. PImage img;
  8. PImage[] images;
  9. int cS, cI, edge;
  10. PFont font;
  11. boolean recording = true;
  12.  
  13. void setup() {
  14.   size(1080, 720);
  15.   images = new PImage[2];
  16.   font = loadFont("Athelas-BoldItalic-48.vlw");
  17.   textFont(font);
  18.   edge = width/10;
  19.   importSources();
  20.   images[cI]=loadImage(sources[cS][0]);
  21.   images[cI+1]=loadImage(sources[cS+1][0]);
  22.   img = images[cI];
  23.   videoExport = new VideoExport(this, "basic.mp4");
  24. }
  25.  
  26. void draw() {
  27.   background(20);
  28.   noStroke();
  29.   fill(255);
  30.   text(sources[cS][1], edge, 100);
  31.   for (int x=edge; x<width-edge; x+=8) {
  32.     int y = frameCount%height;
  33.     int px = (int) map(x, edge, width-edge, 0, img.width);
  34.     int py = (int) map(y, 0, height, 0, img.height);
  35.     float br = brightness(img.get(px, py));
  36.     color f = img.get(px, py);
  37.     //float f = map(br, 0, 255, 20, 255);
  38.     float sz = map(br, 0, 255, 0, height/2);
  39.     fill(f);
  40.     rectMode(CENTER);
  41.     rect(x, height/2, 1, sz);
  42.   }
  43.  
  44.   if (frameCount%350==0) {
  45.     cS++;
  46.     cI = (cI+1)%2;
  47.     img = images[cI];
  48.     thread("preLoad");
  49.   }
  50.    if (recording && frameCount%2==0) videoExport.saveFrame();
  51. }
  52.  
  53. void preLoad() {
  54.   images[(cI+1)%2] = loadImage(sources[cS+1][0]);
  55. }
  56.  
  57. void importSources() {
  58.   //root = loadXML("https://www.pinterest.com/xeronimo/famous-people-monochrome.rss");
  59.   root = loadXML("https://www.pinterest.com/xeronimo/animals-close-up.rss");
  60.   //root = loadXML("https://www.pinterest.com/xeronimo/those-bipeds-known-as-humans.rss");
  61.   //root = loadXML("https://www.pinterest.com/xeronimo/as-far-as-the-eye-can-see.rss");
  62.   channel = root.getChild("channel");
  63.   items = channel.getChildren("item");
  64.   sources = new String[items.length][2];
  65.   for (int i=0; i<items.length; i++) {
  66.     description = items[i].getChild("description");
  67.     title = items[i].getChild("title");
  68.     String d = description.getContent();
  69.     String name = title.getContent();
  70.     String start = "https://";
  71.     String end = ".jpg";
  72.     int indexStart = d.indexOf(start);
  73.     int indexEnd = d.indexOf(end);
  74.     String descr = d.substring(indexStart, indexEnd+4);
  75.     sources[i][0] = descr;
  76.     sources[i][1] = name;
  77.   }
  78. }
  79.  
  80. void keyPressed() {
  81.   recording = false;
  82.   println(recording);
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement