Created
January 6, 2021 08:07
-
-
Save n1ckfg/a815d60c8f779b5ec70d1ca792326169 to your computer and use it in GitHub Desktop.
Illustration of bit depth
This file contains hidden or 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
| 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