clip.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #include "tigr.h"
  2. int main(int argc, char* argv[]) {
  3. Tigr* screen = tigrWindow(320, 240, "Clip", 0);
  4. TPixel c0 = tigrRGB(55, 55, 55);
  5. TPixel c1 = tigrRGB(255, 255, 255);
  6. TPixel c2 = tigrRGB(100, 200, 100);
  7. TPixel c3 = tigrRGBA(100, 100, 200, 150);
  8. while (!tigrClosed(screen) && !tigrKeyDown(screen, TK_ESCAPE)) {
  9. tigrClear(screen, c0);
  10. int cx = screen->w / 2;
  11. int cy = screen->h / 2;
  12. int w = 100;
  13. int d = 50;
  14. tigrClip(screen, cx - d, cy - d, w, w);
  15. tigrFill(screen, cx - d, cy - d, w, w, c1);
  16. tigrRect(screen, cx - w, cy - w, w, w, c2);
  17. tigrFillRect(screen, cx - w, cy - w, w, w, c3);
  18. tigrCircle(screen, cx + d, cy - d, d, c2);
  19. tigrFillCircle(screen, cx + d, cy - d, d, c3);
  20. const char* message = "Half a thought is also a thought";
  21. int tw = tigrTextWidth(tfont, message);
  22. int th = tigrTextHeight(tfont, message);
  23. tigrPrint(screen, tfont, cx - tw / 2, cy + d - th / 2, c2, message);
  24. tigrUpdate(screen);
  25. }
  26. tigrFree(screen);
  27. return 0;
  28. }