Skip to content

Instantly share code, notes, and snippets.

@KrabCode
Created December 14, 2023 09:23
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 KrabCode/938d0b00ea6fa8533309a95b9fdd5987 to your computer and use it in GitHub Desktop.
Save KrabCode/938d0b00ea6fa8533309a95b9fdd5987 to your computer and use it in GitHub Desktop.
Basis for coloring a dot matrix of 64 x 64 points.
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