Created
December 14, 2023 09:23
-
-
Save KrabCode/938d0b00ea6fa8533309a95b9fdd5987 to your computer and use it in GitHub Desktop.
Basis for coloring a dot matrix of 64 x 64 points.
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
import com.krab.lazy.*; | |
int cols = 64; | |
int rows = 64; | |
LazyGui gui; | |
void setup() { | |
size(1280, 1280, P2D); | |
gui = new LazyGui(this, new LazyGuiSettings().setLoadLatestSaveOnStartup(false)); | |
rectMode(CENTER); | |
colorMode(HSB, 1, 1, 1, 1); | |
} | |
void draw() { | |
background(gui.colorPicker("bg", color(0.1f)).hex); | |
translate(width * 0.5f, height * 0.5f); | |
int i = 0; | |
for (int yi = 0; yi < rows; yi++) { | |
for (int xi = 0; xi < cols; xi++) { | |
cell(xi, yi, i++); | |
} | |
} | |
} | |
void cell(int xi, int yi, int i) { | |
gui.pushFolder("cell"); | |
float xn = norm(xi, 0, cols-1); | |
float yn = norm(yi, 0, rows-1); | |
float in = norm(i, 0, cols * rows); | |
float range = gui.slider("range", 1000); | |
float x = -range * 0.5f + xn * range; | |
float y = -range * 0.5f + yn * range; | |
float size = gui.slider("size", 10); | |
float theta = atan2(yi - rows / 2, xi - cols / 2); | |
float thetaNorm = (PI + theta) / TAU; | |
fill(color(1, 1, 1)); | |
noStroke(); | |
rect(x, y, size, size); | |
gui.popFolder(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment