You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
2.8 KiB

  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. SetTargetFPS(60);
  20. //--------------------------------------------------------------------------------------
  21. // Main game loop
  22. while (!WindowShouldClose()) // Detect window close button or ESC key
  23. {
  24. // Update
  25. //----------------------------------------------------------------------------------
  26. // TODO: Update your variables here
  27. //----------------------------------------------------------------------------------
  28. // Draw
  29. //----------------------------------------------------------------------------------
  30. BeginDrawing();
  31. ClearBackground(RAYWHITE);
  32. DrawText("some basic shapes available on raylib", 20, 20, 20, DARKGRAY);
  33. DrawLine(18, 42, screenWidth - 18, 42, BLACK);
  34. DrawCircle(screenWidth/4, 120, 35, DARKBLUE);
  35. DrawCircleGradient(screenWidth/4, 220, 60, GREEN, SKYBLUE);
  36. DrawCircleLines(screenWidth/4, 340, 80, DARKBLUE);
  37. DrawRectangle(screenWidth/4*2 - 60, 100, 120, 60, RED);
  38. DrawRectangleGradientH(screenWidth/4*2 - 90, 170, 180, 130, MAROON, GOLD);
  39. DrawRectangleLines(screenWidth/4*2 - 40, 320, 80, 60, ORANGE);
  40. DrawTriangle((Vector2){screenWidth/4*3, 80},
  41. (Vector2){screenWidth/4*3 - 60, 150},
  42. (Vector2){screenWidth/4*3 + 60, 150}, VIOLET);
  43. DrawTriangleLines((Vector2){screenWidth/4*3, 160},
  44. (Vector2){screenWidth/4*3 - 20, 230},
  45. (Vector2){screenWidth/4*3 + 20, 230}, DARKBLUE);
  46. DrawPoly((Vector2){screenWidth/4*3, 320}, 6, 80, 0, BROWN);
  47. EndDrawing();
  48. //----------------------------------------------------------------------------------
  49. }
  50. // De-Initialization
  51. //--------------------------------------------------------------------------------------
  52. CloseWindow(); // Close window and OpenGL context
  53. //--------------------------------------------------------------------------------------
  54. return 0;
  55. }