VRSLogicUnit
YaBB Newbies
Offline
Posts: 3
RSS Image Sequencer
Mar 18th , 2008, 4:47am
Hello everyone, I'm a completely new to Processing but just starting to get the hang of it. I'm trying to grab images from an RSS feed and then sequence them - just to play in a loop one after each other. I then want to be able to add to this sequence as the RSS feed is updated. I've found this example that grabs thumbnail images and displays them in a circle. Is there a way of modifying this code? Also is there a way of using multiple RSS feeds? Or maybe even the video from a RSS feed? /** * Loads RSS feed and displays item images. * Move the mouse to rotate and scale the image wheel. * * (c) 2008 Till Nagel, btk.tillnagel.com */ import processing.opengl.*; import processing.xml.*; // The items array Item[] items; void setup() { size(1280, 800, OPENGL); print("Loading feed, and images ..."); // Loads RSS feed and gets image of each item XMLElement rss = new XMLElement(this, "http://www.archive.org/services/collection-rss.php?mediatype=movies"); XMLElement[] imageURLElements = rss.getChildren("channel/category/media:thumbnails"); items = new Item[imageURLElements.length]; // Calculate degreeStep to arrange items equally on a circle float degreeStep = 360.0 / items.length; // Loads image and creates Item for each feed item for (int i = 0; i < items.length; i++) { String imageURL = imageURLElements[i].getStringAttribute("url"); PImage img = loadImage(imageURL); items[i] = new Item(img, degreeStep * i, 300, 0); } println(" done."); } void draw() { float degreeChange = (mouseX-width/2)/80.0; float distance = (mouseY-height/2)/80.0; background(0); translate(width/2, height/2); // Displays each item for (int i = 0; i < items.length; i++) { items[i].display(); // Rotate it according to the vertical mouse position items[i].degree += degreeChange; // and move it according to the horizontal mouse position items[i].x += distance; } } This is in a new tab // Item to store image, degree to rotate, and position class Item { PImage img; float x; float y; float degree; // Creates new Item. Item(PImage img, float degree, float x, float y) { this.x = x; this.y = y; this.degree = degree; this.img = img; } // Displays image rotated around the current origin at the given position. void display() { pushMatrix(); rotate(radians(degree)); translate(x, y); rotate(radians(-degree)); // The center point of the image is used image(img, -img.width/2, -img.height/2); popMatrix(); } } Thanks for your help, it's much appreciated. Apologies if this seems really basic.