Advertisement
xeromino

scanned.stars

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