Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
int boxSize = 50;
boolean bitmap[][] = new boolean[3][8];
void setup() {
size(150, 400);
background(225, 219, 203);
// horizontal lines
for (int i=1; i<3; i++) {
line(i * boxSize, 0, i * boxSize, height);
}
// vertical lines
for (int i=1; i<8; i++) {
line(0, i*boxSize, width, i*boxSize);
}
for (int x=0; x<bitmap.length; x++) {
for (int y=0; y<bitmap[x].length; y++) {
bitmap[x][y] = false;
}
}
}
void draw() {
for (int x=0; x<bitmap.length; x++) {
for (int y=0; y<bitmap[x].length; y++) {
if (bitmap[x][y]) {
fill(88, 83, 85);
} else {
fill(225, 219, 203);
}
rect(x * boxSize, y * boxSize, boxSize, boxSize);
}
}
}
void mouseClicked() {
toggleBox(mouseX/boxSize, mouseY/boxSize);
}
void keyPressed() {
String[] character = new String[3];
for (int x=0; x<bitmap.length; x++) {
byte b = 0x0;
for (int y=0; y<bitmap[x].length; y++) {
if (bitmap[x][y]) {
b |= ((byte)1 << y);
}
}
character[x] = "0x" + hex(b);
}
println("\t" + join(character, ","));
}
void toggleBox(int x, int y) {
bitmap[x][y] = !bitmap[x][y];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment