Created
December 20, 2019 06:53
-
-
Save marcedwards/f325b6198fcd728096adfacae48f0bb9 to your computer and use it in GitHub Desktop.
HEX to swatches in Processing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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