/** * Loads RSS feed and visualizes the titles in a very simple manner. * Color and bar depend on the length of the corresponding title. * * (c) 2008 Till Nagel, btk.tillnagel.com */ import processing.xml.*; // Array to store titles String[] titles; PFont font; void setup() { size(700, 300); background(0); noStroke(); // Setup font font = loadFont("Calibri-12.vlw"); textFont(font, 12); // Load RSS feed String url = "http://processing.org/updates.xml"; XMLElement rss = new XMLElement(this, url); // Get title of each element XMLElement[] titleXMLElements = rss.getChildren("channel/item/title"); titles = new String[titleXMLElements.length]; for (int i = 0; i < titleXMLElements.length; i++) { String title = titleXMLElements[i].getContent(); // Store title in array for later use titles[i] = title; } } void draw() { background(255); // Draw all titles with bars and colors depending on its length for (int i = 0; i < titles.length; i++) { float y = (i+1) * 15; fill(255 - constrain(titles[i].length(), 0, 255)); rect(8, y - 11, 14, 14); fill(127, 100); rect(23, y - 11, titles[i].length() * 2, 14); fill(0, 220); text(titles[i], 26, y); } }