Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import com.hamoid.*;
- VideoExport videoExport;
- XML root, channel, item, description, title;
- XML[] items;
- String[][] sources;
- PImage img;
- PImage[] images;
- int cS, cI, edge;
- PFont font;
- boolean recording = true;
- void setup() {
- size(1080, 720);
- images = new PImage[2];
- font = loadFont("Athelas-BoldItalic-48.vlw");
- textFont(font);
- edge = width/10;
- importSources();
- images[cI]=loadImage(sources[cS][0]);
- images[cI+1]=loadImage(sources[cS+1][0]);
- img = images[cI];
- videoExport = new VideoExport(this, "basic.mp4");
- }
- void draw() {
- background(20);
- noStroke();
- fill(255);
- text(sources[cS][1], edge, 100);
- for (int x=edge; x<width-edge; x+=8) {
- int y = frameCount%height;
- int px = (int) map(x, edge, width-edge, 0, img.width);
- int py = (int) map(y, 0, height, 0, img.height);
- float br = brightness(img.get(px, py));
- color f = img.get(px, py);
- //float f = map(br, 0, 255, 20, 255);
- float sz = map(br, 0, 255, 0, height/2);
- fill(f);
- rectMode(CENTER);
- rect(x, height/2, 1, sz);
- }
- if (frameCount%350==0) {
- cS++;
- cI = (cI+1)%2;
- img = images[cI];
- thread("preLoad");
- }
- if (recording && frameCount%2==0) videoExport.saveFrame();
- }
- void preLoad() {
- images[(cI+1)%2] = loadImage(sources[cS+1][0]);
- }
- void importSources() {
- //root = loadXML("https://www.pinterest.com/xeronimo/famous-people-monochrome.rss");
- root = loadXML("https://www.pinterest.com/xeronimo/animals-close-up.rss");
- //root = loadXML("https://www.pinterest.com/xeronimo/those-bipeds-known-as-humans.rss");
- //root = loadXML("https://www.pinterest.com/xeronimo/as-far-as-the-eye-can-see.rss");
- channel = root.getChild("channel");
- items = channel.getChildren("item");
- sources = new String[items.length][2];
- for (int i=0; i<items.length; i++) {
- description = items[i].getChild("description");
- title = items[i].getChild("title");
- String d = description.getContent();
- String name = title.getContent();
- String start = "https://";
- String end = ".jpg";
- int indexStart = d.indexOf(start);
- int indexEnd = d.indexOf(end);
- String descr = d.substring(indexStart, indexEnd+4);
- sources[i][0] = descr;
- sources[i][1] = name;
- }
- }
- void keyPressed() {
- recording = false;
- println(recording);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement