Subversion Repositories Kolibri OS

Rev

Rev 8818 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. #include <clayer/rasterworks.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <sys/ksys.h>
  5.  
  6. // Sizes
  7. int x_size = 768, y_size = 256;
  8.  
  9. // Out example string
  10. char* string = "Пример/Example";
  11.  
  12. int main()
  13. {
  14.     // Count length
  15.     int ln_str = countUTF8Z(string, -1);
  16.  
  17.     // Create image buffer
  18.     void* buffi = malloc(x_size * y_size * 3 * sizeof(char) + 8);
  19.  
  20.     // Set sizes
  21.     *((int*)buffi) = x_size;
  22.     *((int*)buffi + 1) = y_size;
  23.  
  24.     // Fill color
  25.     memset((char*)buffi + 8, 0xFF, x_size * y_size * 3);
  26.  
  27.     // Draw text on buffer
  28.     drawText(buffi, 5, 0, string, ln_str, 0xFF000000, 0x30C18);
  29.     drawText(buffi, 5, 32, string, ln_str, 0xFF000000, 0x1030C18);
  30.     drawText(buffi, 5, 64, string, ln_str, 0xFF000000, 0x2030C18);
  31.     drawText(buffi, 5, 96, string, ln_str, 0xFF000000, 0x4030C18);
  32.     drawText(buffi, 5, 128, string, ln_str, 0xFF000000, 0x8030C18);
  33.     drawText(buffi, 5, 160, string, ln_str, 0xFF000000, 0x0F031428);
  34.  
  35.     while (1) {
  36.         switch (_ksys_get_event()) {
  37.         case KSYS_EVENT_REDRAW:
  38.             _ksys_start_draw();
  39.             _ksys_create_window(50, 50, 800, 300, "Rasterworks Example", 0x999999, 0x34);
  40.             _ksys_draw_bitmap(buffi + 8, 10, 10, 768, 256);
  41.             _ksys_end_draw();
  42.             break;
  43.  
  44.         case KSYS_EVENT_BUTTON:
  45.             if (_ksys_get_button() == 1)
  46.                 exit(0);
  47.             break;
  48.         };
  49.     }
  50.     return 0;
  51. }
  52.