Generate mandelbrot images using many clustered computers

font.c 3.0KB

    #include "types.h" //Stole this from SteveOS char characters[26 * 8 + 31 * 8 + 16*8] = { 24,24,0,24,60,60,126,126, 0,0,0,0,108,108,108,108, 108,254,254,108,108,254,254,108, 16,124,124,16,8,124,124,16, 198,206,28,56,112,224,198,6, 16,124,64,124,64,64,124,16, 0,0,0,0,6,6,6,6, 24,30,14,6,6,14,30,24, 6,30,28,24,24,28,30,6, 146,84,56,254,56,84,146,16, 0,24,24,126,126,24,24,0, 28,56,48,0,0,0,0,0, 0,0,0,252,252,0,0,0, 14,14,14,0,0,0,0,0, 6,14,28,56,112,224,192,0, 254,254,206,222,246,230,254,254, 254,254,48,48,48,62,60,56, 254,254,28,56,118,230,254,254, 254,254,192,254,254,192,254,254, 48,48,48,254,254,54,54,54, 254,254,198,192,254,6,254,254, 254,254,198,254,254,6,254,254, 48,48,48,48,48,48,62,62, 124,238,198,254,124,198,238,124, 192,192,254,254,198,198,254,254, 24,24,0,0,0,0,24,24, 12,28,56,48,0,0,48,48, 48,56,28,14,14,28,56,48, 0,0,254,254,0,254,254,0, 24,56,112,224,224,112,56,24, 24,24,0,120,120,96,120,120, 254,254,6,246,246,198,254,254, 198,198,254,254,198,238,124,56, 62,126,102,126,126,102,126,62, 126,126,6,6,6,6,126,126, 62,126,230,198,198,230,126,62, 254,254,6,30,30,6,254,254, 6,6,126,126,6,6,254,254, 254,254,198,246,246,6,254,254, 198,198,198,254,254,198,198,198, 126,126,24,24,24,24,126,126, 62,62,54,54,48,48,48,48, 102,118,62,30,30,62,118,102, 62,62,6,6,6,6,6,6, 198,198,198,214,254,254,238,198, 198,198,246,246,222,222,198,198, 254,254,198,198,198,198,254,254, 6,6,62,126,102,102,126,62, 62,126,246,246,198,198,254,254, 230,118,62,126,102,102,126,62, 126,126,112,56,28,14,126,126, 24,24,24,24,24,24,126,126, 254,254,198,198,198,198,198,198, 24,60,126,102,102,102,102,102, 198,238,254,254,214,198,198,198, 198,238,124,56,56,124,238,198, 24,24,24,24,60,126,102,102, 126,126,12,28,56,48,126,126, 30,30,6,6,6,6,30,30, 192,224,112,56,28,14,6,0, 30,30,24,24,24,24,30,30, 0,0,0,132,204,252,120,48, 254,254,0,0,0,0,0,0, 0,0,0,0,0,12,14,6, 192,254,254,198,198,254,254,192, 62,126,102,102,126,62,6,6, 62,62,6,62,62,0,0,0, 254,254,246,254,254,192,192,192, 254,254,6,246,246,198,254,254, 24,126,126,24,216,216,248,248, 126,64,126,126,102,102,126,126, 102,102,126,126,6,6,6,6, 6,6,6,6,6,0,6,6 }; void putPixel(FBuffer buf, int x, int y, Pixel fg) { if(x > 0 && x < buf.w && y > 0 && y < buf.h) { buf.buf[x + buf.w * y] = fg; } } void drawChar(FBuffer buf, int x, int y, char c, Pixel fg) { if(c == 124) // | { for(int r = 0; r < 8; r++) { putPixel(buf, x + 3, y - r, fg); putPixel(buf, x + 4, y - r, fg); } } else { if(c >= 97) //Lowercase -> Uppercase { c -= 32; } c -= 33; //So we can do a lookup in the above array for(int r = 0; r < 8; r++) //Rows { char row = characters[c * 8 + r]; for (int i = 0; i < 8; i++) { if (row&(1 << i)) { putPixel(buf, x + i, y - r, fg); } } } } } void bufPrint(FBuffer buf, int x, int y, char *s, Pixel fg) { int i = 0; int xCur = x; while (s[i] != 0) { if(s[i] == '\r') { xCur = x; } else if(s[i] == '\n') { y += 12; } else { drawChar(buf, xCur, y, s[i], fg); xCur += 8; } i++; } }