Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

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