Skip to content

Instantly share code, notes, and snippets.

@marcedwards
Created December 20, 2019 06:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcedwards/f325b6198fcd728096adfacae48f0bb9 to your computer and use it in GitHub Desktop.
Save marcedwards/f325b6198fcd728096adfacae48f0bb9 to your computer and use it in GitHub Desktop.
HEX to swatches in Processing
void setup() {
size(400, 400);
noLoop();
noStroke();
}
void draw() {
background(0);
color[] colors = { #811eff, #ff0000, #811eff, #ff0000, #00ff00, #00ffff, #811eff, #ff0000, #811eff, #ff0000, #00ff00, #00ffff, #811eff, #ff0000, #811eff, #ff0000, #00ff00, #00ffff, #811eff, #ff0000, #811eff, #ff0000, #00ff00, #00ffff };
int size = 40;
int items = floor(width / size);
for (int i = 0; i < colors.length; i++) {
fill(colors[i]);
int x = (i % items) * size;
int y = floor(i / items) * size;
rect(x, y, size, size);
}
// Un-comment the line below to save a PNG
//saveFrame("swatches.png");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment