Skip to content

Instantly share code, notes, and snippets.

@n1ckfg
Created January 6, 2021 08:07
Show Gist options
  • Select an option

  • Save n1ckfg/a815d60c8f779b5ec70d1ca792326169 to your computer and use it in GitHub Desktop.

Select an option

Save n1ckfg/a815d60c8f779b5ec70d1ca792326169 to your computer and use it in GitHub Desktop.
Illustration of bit depth
int stepW, stepH;
color colA = color(255,0,0);
color colB = color(0,0,255);
color fillCol = colA;
int numRows = 5;
void setup() {
size(1024, 768, P2D);
noStroke();
stepH = height/numRows;
}
void draw() {
for (int i=0; i<numRows; i++) {
drawLines(i, i*2+2);
}
}
void drawLines(int y, int exp) {
stepW = width / (int) pow(2, exp);
for (int i=0; i<width; i++) {
fillCol = colA;
if (i %2 == 0) fillCol = colB;
fill(fillCol);
rect(i*stepW, y*stepH, stepW, stepH);
}
}
void keyPressed() {
saveFrame("output.png");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment