Skip to content

Instantly share code, notes, and snippets.

@hamoid
Created February 7, 2015 13:07
Show Gist options
  • Save hamoid/015f23936e7abf4f770d to your computer and use it in GitHub Desktop.
Save hamoid/015f23936e7abf4f770d to your computer and use it in GitHub Desktop.
Processing function to get a random color set from ColourLovers
void setup() {
size(displayWidth, displayHeight);
int[] colors = getColorLove();
println(colors);
noStroke();
for(float x=0; x<width; x+=random(100)) {
fill(colors[(int)random(colors.length)]);
rect(x, 0, width, height);
}
}
int[] getColorLove() {
XML xml = loadXML("http://www.colourlovers.com/api/palettes/random");
XML[] xcolors = xml.getChild("palette").getChild("colors").getChildren("hex");
int[] colors = new int[xcolors.length];
int i = 0;
for(XML c : xcolors) {
colors[i++] = unhex("FF" + c.getContent());
}
return colors;
}
@hamoid
Copy link
Author

hamoid commented May 22, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment