daily pastebin goal
76%
SHARE
TWEET

Nikita

a guest Oct 12th, 2017 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <progbase.h>
  3. #include <progbase/console.h>
  4.  
  5. int main(void)
  6. {
  7.     Console_clear();
  8.     Console_reset();
  9. char image[28][28] = {
  10.     { '1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1' },
  11.     { '1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1' },
  12.     { '1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1' },
  13.     { '1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1' },
  14.     { '1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1' },
  15.     { '1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1' },
  16.     { 'F','F','F','F','F','F','F','F','F','F','F','F','F','F','F','F','F','F','F','F','F','F','F','F','F','F','F','F' },
  17.     { '4','F','4','4','F','F','F','F','F','F','6','6','6','6','6','6','6','6','F','F','F','F','F','F','F','F','F','F' },
  18.     { '4','4','4','F','F','4','4','4','F','6','6','6','6','6','6','6','6','6','6','F','F','F','F','F','F','F','F','F' },
  19.     { '4','4','4','4','4','4','F','F','F','6','6','6','6','6','6','6','6','6','6','F','F','F','F','F','F','F','F','F' },
  20.     { '8','4','4','4','4','4','4','8','8','8','8','8','8','8','8','8','8','8','8','8','8','8','8','8','8','8','8','8' },
  21.     { '4','4','1','1','8','8','4','4','8','8','8','8','8','8','8','8','8','8','8','8','8','8','8','8','8','8','8','8' },
  22.     { '8','1','1','1','8','8','8','8','8','8','8','8','8','8','8','8','8','8','8','8','8','8','8','8','C','8','8','C' },
  23.     { '8','1','1','8','8','8','8','8','8','8','8','8','8','8','8','8','8','8','8','8','8','8','8','8','8','8','8','8' },
  24.     { '1','1','1','C','8','8','8','8','8','8','8','8','8','C','8','C','8','C','8','C','8','8','8','8','C','C','C','C' },
  25.     { '1','8','8','8','8','C','8','C','C','8','8','8','8','8','8','8','C','C','8','8','8','8','8','C','8','C','C','C' },
  26.     { '8','8','8','8','C','C','C','C','8','8','8','8','8','8','8','8','8','8','8','C','8','8','8','C','C','8','8','C' },
  27.     { '8','8','8','8','8','8','8','8','C','8','8','C','8','8','C','8','8','8','8','8','8','8','C','C','C','C','8','C' },
  28.     { 'C','C','C','C','C','8','8','8','8','8','C','C','C','C','C','C','C','C','8','8','8','C','C','C','C','C','8','C' },
  29.     { '8','8','C','C','C','C','C','C','8','C','8','8','8','C','C','C','8','8','8','8','8','8','8','8','8','8','8','C' },
  30.     { 'C','8','8','8','8','8','8','8','8','8','8','8','8','8','8','8','C','C','C','C','C','C','8','8','8','8','8','8' },
  31.     { '8','8','8','8','8','8','8','8','8','8','8','8','8','8','8','8','8','8','8','8','8','8','8','8','8','8','8','8' },
  32.     { '1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1' },
  33.     { '1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1' },
  34.     { '1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1' },
  35.     { '1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1' },
  36.     { '1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1' },
  37.     { '1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1' }
  38. };
  39. const char colorsTable[16][2] = {
  40.         {'0', BG_BLACK},
  41.         {'1', BG_INTENSITY_BLACK},
  42.         {'2', BG_INTENSITY_RED},
  43.         {'3', BG_RED},
  44.         {'4', BG_GREEN},
  45.         {'5', BG_INTENSITY_GREEN},
  46.         {'6', BG_YELLOW},
  47.         {'7', BG_GREEN},
  48.         {'8', BG_BLUE},
  49.         {'9', BG_GREEN},
  50.         {'A', BG_MAGENTA},
  51.         {'B', BG_WHITE},
  52.         {'C', BG_INTENSITY_BLUE},
  53.         {'D', BG_INTENSITY_MAGENTA},
  54.         {'E', BG_INTENSITY_CYAN},
  55.         {'F', BG_INTENSITY_WHITE}};
  56. //
  57.     int colorsTableLength = sizeof(colorsTable) / sizeof(colorsTable[0]);
  58.     char colorsPalette[] = "0123456789ABCDEF";
  59.     int colorsPaletteLength = sizeof(colorsPalette) / sizeof(colorsPalette[0]);
  60.     //
  61.     int imageTableLen = sizeof(image[0]) / sizeof(image[0][0]);
  62. //
  63. int count          = 0,
  64.       buffer         = 0,
  65.       colorPairIndex = 0;
  66.   Console_clear();
  67.     for (int i = 0; i < colorsPaletteLength; i++)
  68.     {
  69.         char colorCode = '\0';
  70.         char color = '\0';
  71.        
  72.         colorCode = colorsPalette[i];
  73.        
  74.         for (colorPairIndex = 0; colorPairIndex < colorsTableLength; colorPairIndex++)
  75.         {
  76.             char colorPairCode = colorsTable[colorPairIndex][0];
  77.             char colorPairColor = colorsTable[colorPairIndex][1];
  78.             if (colorCode == colorPairCode)
  79.             {
  80.                 color = colorPairColor;
  81.                 break;
  82.             }
  83.         }
  84.      
  85.         Console_setCursorAttribute(color);
  86.         putchar(' ');
  87.     }
  88.     printf("\n");
  89. //
  90.   for (int i = 0; i < imageTableLen; i++) {
  91.         for (int j = 0; j < imageTableLen; j++) {
  92.             char colorCode = '\0';
  93.             char color = '\0';
  94.             colorCode = image[i][j];
  95.             for (colorPairIndex = 0; colorPairIndex < colorsTableLength; colorPairIndex++) {
  96.                 char colorPairCode = colorsTable[colorPairIndex][0];
  97.                 char colorPairColor = colorsTable[colorPairIndex][1];
  98.                 if (colorCode == colorPairCode) {
  99.                     color = colorPairColor;
  100.                     break;
  101.                 }
  102.             }
  103.             sleepMillis(20);
  104.            
  105.           Console_setCursorAttribute(color);
  106.             putchar(' ');
  107.         }
  108.         Console_setCursorAttribute(BG_DEFAULT);
  109.     putchar('\n');
  110.   }
  111.  
  112.  return 0;
  113.  
  114.     }
RAW Paste Data
Top