Generate mandelbrot images using many clustered computers
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

143 lines
3.0 KiB

  1. #include "types.h"
  2. //Stole this from SteveOS
  3. char characters[26 * 8 + 31 * 8 + 16*8] = {
  4. 24,24,0,24,60,60,126,126,
  5. 0,0,0,0,108,108,108,108,
  6. 108,254,254,108,108,254,254,108,
  7. 16,124,124,16,8,124,124,16,
  8. 198,206,28,56,112,224,198,6,
  9. 16,124,64,124,64,64,124,16,
  10. 0,0,0,0,6,6,6,6,
  11. 24,30,14,6,6,14,30,24,
  12. 6,30,28,24,24,28,30,6,
  13. 146,84,56,254,56,84,146,16,
  14. 0,24,24,126,126,24,24,0,
  15. 28,56,48,0,0,0,0,0,
  16. 0,0,0,252,252,0,0,0,
  17. 14,14,14,0,0,0,0,0,
  18. 6,14,28,56,112,224,192,0,
  19. 254,254,206,222,246,230,254,254,
  20. 254,254,48,48,48,62,60,56,
  21. 254,254,28,56,118,230,254,254,
  22. 254,254,192,254,254,192,254,254,
  23. 48,48,48,254,254,54,54,54,
  24. 254,254,198,192,254,6,254,254,
  25. 254,254,198,254,254,6,254,254,
  26. 48,48,48,48,48,48,62,62,
  27. 124,238,198,254,124,198,238,124,
  28. 192,192,254,254,198,198,254,254,
  29. 24,24,0,0,0,0,24,24,
  30. 12,28,56,48,0,0,48,48,
  31. 48,56,28,14,14,28,56,48,
  32. 0,0,254,254,0,254,254,0,
  33. 24,56,112,224,224,112,56,24,
  34. 24,24,0,120,120,96,120,120,
  35. 254,254,6,246,246,198,254,254,
  36. 198,198,254,254,198,238,124,56,
  37. 62,126,102,126,126,102,126,62,
  38. 126,126,6,6,6,6,126,126,
  39. 62,126,230,198,198,230,126,62,
  40. 254,254,6,30,30,6,254,254,
  41. 6,6,126,126,6,6,254,254,
  42. 254,254,198,246,246,6,254,254,
  43. 198,198,198,254,254,198,198,198,
  44. 126,126,24,24,24,24,126,126,
  45. 62,62,54,54,48,48,48,48,
  46. 102,118,62,30,30,62,118,102,
  47. 62,62,6,6,6,6,6,6,
  48. 198,198,198,214,254,254,238,198,
  49. 198,198,246,246,222,222,198,198,
  50. 254,254,198,198,198,198,254,254,
  51. 6,6,62,126,102,102,126,62,
  52. 62,126,246,246,198,198,254,254,
  53. 230,118,62,126,102,102,126,62,
  54. 126,126,112,56,28,14,126,126,
  55. 24,24,24,24,24,24,126,126,
  56. 254,254,198,198,198,198,198,198,
  57. 24,60,126,102,102,102,102,102,
  58. 198,238,254,254,214,198,198,198,
  59. 198,238,124,56,56,124,238,198,
  60. 24,24,24,24,60,126,102,102,
  61. 126,126,12,28,56,48,126,126,
  62. 30,30,6,6,6,6,30,30,
  63. 192,224,112,56,28,14,6,0,
  64. 30,30,24,24,24,24,30,30,
  65. 0,0,0,132,204,252,120,48,
  66. 254,254,0,0,0,0,0,0,
  67. 0,0,0,0,0,12,14,6,
  68. 192,254,254,198,198,254,254,192,
  69. 62,126,102,102,126,62,6,6,
  70. 62,62,6,62,62,0,0,0,
  71. 254,254,246,254,254,192,192,192,
  72. 254,254,6,246,246,198,254,254,
  73. 24,126,126,24,216,216,248,248,
  74. 126,64,126,126,102,102,126,126,
  75. 102,102,126,126,6,6,6,6,
  76. 6,6,6,6,6,0,6,6
  77. };
  78. void putPixel(FBuffer buf, int x, int y, Pixel fg)
  79. {
  80. if(x > 0 && x < buf.w &&
  81. y > 0 && y < buf.h)
  82. {
  83. buf.buf[x + buf.w * y] = fg;
  84. }
  85. }
  86. void drawChar(FBuffer buf, int x, int y, char c, Pixel fg)
  87. {
  88. if(c == 124) // |
  89. {
  90. for(int r = 0; r < 8; r++)
  91. {
  92. putPixel(buf, x + 3, y - r, fg);
  93. putPixel(buf, x + 4, y - r, fg);
  94. }
  95. }
  96. else
  97. {
  98. if(c >= 97) //Lowercase -> Uppercase
  99. {
  100. c -= 32;
  101. }
  102. c -= 33; //So we can do a lookup in the above array
  103. for(int r = 0; r < 8; r++) //Rows
  104. {
  105. char row = characters[c * 8 + r];
  106. for (int i = 0; i < 8; i++)
  107. {
  108. if (row&(1 << i))
  109. {
  110. putPixel(buf, x + i, y - r, fg);
  111. }
  112. }
  113. }
  114. }
  115. }
  116. void bufPrint(FBuffer buf, int x, int y, char *s, Pixel fg)
  117. {
  118. int i = 0;
  119. int xCur = x;
  120. while (s[i] != 0)
  121. {
  122. if(s[i] == '\r')
  123. {
  124. xCur = x;
  125. }
  126. else if(s[i] == '\n')
  127. {
  128. y += 12;
  129. }
  130. else
  131. {
  132. drawChar(buf, xCur, y, s[i], fg);
  133. xCur += 8;
  134. }
  135. i++;
  136. }
  137. }