Skip to content

Instantly share code, notes, and snippets.

@andreburto
Created August 27, 2016 23:37
Show Gist options
  • Save andreburto/96831365dd1072b1039ddb6b5ab5bab8 to your computer and use it in GitHub Desktop.
Save andreburto/96831365dd1072b1039ddb6b5ab5bab8 to your computer and use it in GitHub Desktop.
Draws circles and makes a picture.
import java.util.*;
XML xml;
String linkUrl = "http://pics.mytrapster.com/yvonne-list.php";
int count = 0;
int w = 100;
float xcoord = 0;
float ycoord = 0;
class Yvonne {
public String full;
public String thumb;
public Yvonne(String f, String t) {
this.full = f;
this.thumb = t;
}
}
ArrayList<Yvonne> pics;
void setup() {
pics = new ArrayList<Yvonne>();
xml = loadXML(linkUrl);
XML[] images = xml.getChildren("image");
for(int c = 0; c < images.length; c++) {
String thumb = images[c].getChild(1).getContent();
String full = images[c].getChild(0).getContent();
pics.add(new Yvonne(full, thumb));
}
size(displayWidth, displayHeight, P3D);
strokeWeight(3);
stroke(#deedee);
background(#000000);
randomSeed(millis());
}
void draw() {
randCoords();
imgOne();
delay(1000);
count++;
if (count == 60) {
save("yvonne.jpg");
count = 0;
}
}
float adjustCoord(float on, float r) {
if (on < r) {
return r - 100.0;
} else {
return r + 100.0;
}
}
void randCoords() {
xcoord = adjustCoord(xcoord, random(-100, width - 100));
ycoord = adjustCoord(ycoord, random(-100, height - 100));
}
void imgOne() {
int count = int(random(0, pics.size() - 1));
PImage img = loadImage(pics.get(count).thumb, "png");
if (img.width > img.height) {
w = img.height/2;
} else {
w = img.width/2;
}
translate(xcoord,ycoord);
beginShape();
texture(img);
for(int x=0; x < 360; x++) {
float xnew = sin(radians(x))*w + w;
float ynew = cos(radians(x))*w + w;
vertex(xnew, ynew, xnew, ynew);
}
endShape(CLOSE);
}
void delay(int wait) {
int time = millis();
while(millis() - time < wait) { ; };
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment