Hi everyone.
I was trying to come up with a function to extract colours from the URL from coolors.com to easily change colour pallets. This is an idea I’ve seen done for P5 projects, but I’d like it for Processing.
For some reason, I am able to get the colours and apply them to the background, but not to any object.
Anyone know why that might be?
String colors = "https://coolors.co/fec5bb-fcd5ce-fae1dd-f8edeb-e8e8e4-d8e2dc-ece4db-ffe5d9-ffd7ba-fec89a";
color[] pal;
color pallete;
void setup() {
size(800, 800);
smooth();
pal = createPallete(colors);
}
void draw() {
pallete = pal[int(random(pal.length))];
background(pallete);
pallete = pal[int(random(pal.length))];
fill(pallete);
ellipse(width/2, height/2, 400, 400);
noLoop();
}
color[] createPallete(String colors) {
String[] clrs = splitTokens(colors, "/");
String[] c = splitTokens(clrs[2], "-");
//String[] a = new String[c.length];
color[] col = new color[c.length];
for (int i = 0; i < c.length; i++) {
//println(c[i]);
//a[i] = "#"+c[i];
col[i] = unhex(c[i]);
}
return col;
}
void mousePressed() {
clear();
redraw();
}