shapes_basic_shapes.c 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*******************************************************************************************
  2. *
  3. * raylib [shapes] example - Draw basic shapes 2d (rectangle, circle, line...)
  4. *
  5. * This example has been created using raylib 1.0 (www.raylib.com)
  6. * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
  7. *
  8. * Copyright (c) 2014 Ramon Santamaria (@raysan5)
  9. *
  10. ********************************************************************************************/
  11. #include "raylib.h"
  12. int main()
  13. {
  14. // Initialization
  15. //--------------------------------------------------------------------------------------
  16. int screenWidth = 800;
  17. int screenHeight = 450;
  18. InitWindow(screenWidth, screenHeight, "raylib [shapes] example - basic shapes drawing");
  19. //--------------------------------------------------------------------------------------
  20. // Main game loop
  21. while (!WindowShouldClose()) // Detect window close button or ESC key
  22. {
  23. // Update
  24. //----------------------------------------------------------------------------------
  25. // TODO: Update your variables here
  26. //----------------------------------------------------------------------------------
  27. // Draw
  28. //----------------------------------------------------------------------------------
  29. BeginDrawing();
  30. ClearBackground(RAYWHITE);
  31. DrawText("some basic shapes available on raylib", 20, 20, 20, DARKGRAY);
  32. DrawLine(18, 42, screenWidth - 18, 42, BLACK);
  33. DrawCircle(screenWidth/4, 120, 35, DARKBLUE);
  34. DrawCircleGradient(screenWidth/4, 220, 60, GREEN, SKYBLUE);
  35. DrawCircleLines(screenWidth/4, 340, 80, DARKBLUE);
  36. DrawRectangle(screenWidth/4*2 - 60, 100, 120, 60, RED);
  37. DrawRectangleGradient(screenWidth/4*2 - 90, 170, 180, 130, MAROON, GOLD);
  38. DrawRectangleLines(screenWidth/4*2 - 40, 320, 80, 60, ORANGE);
  39. DrawTriangle((Vector2){screenWidth/4*3, 80},
  40. (Vector2){screenWidth/4*3 - 60, 150},
  41. (Vector2){screenWidth/4*3 + 60, 150}, VIOLET);
  42. DrawTriangleLines((Vector2){screenWidth/4*3, 160},
  43. (Vector2){screenWidth/4*3 - 20, 230},
  44. (Vector2){screenWidth/4*3 + 20, 230}, DARKBLUE);
  45. DrawPoly((Vector2){screenWidth/4*3, 320}, 6, 80, 0, BROWN);
  46. EndDrawing();
  47. //----------------------------------------------------------------------------------
  48. }
  49. // De-Initialization
  50. //--------------------------------------------------------------------------------------
  51. CloseWindow(); // Close window and OpenGL context
  52. //--------------------------------------------------------------------------------------
  53. return 0;
  54. }