Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

@hamoid hamoid commented May 22, 2016

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