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.

59 lines
2.2 KiB

  1. /*******************************************************************************************
  2. *
  3. * raylib [shapes] example - Cubic-bezier lines
  4. *
  5. * This example has been created using raylib 1.7 (www.raylib.com)
  6. * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
  7. *
  8. * Copyright (c) 2017 Ramon Santamaria (@raysan5)
  9. *
  10. ********************************************************************************************/
  11. #include "raylib.h"
  12. int main(void)
  13. {
  14. // Initialization
  15. //--------------------------------------------------------------------------------------
  16. const int screenWidth = 800;
  17. const int screenHeight = 450;
  18. SetConfigFlags(FLAG_MSAA_4X_HINT);
  19. InitWindow(screenWidth, screenHeight, "raylib [shapes] example - cubic-bezier lines");
  20. Vector2 start = { 0, 0 };
  21. Vector2 end = { screenWidth, screenHeight };
  22. SetTargetFPS(60); // Set our game to run at 60 frames-per-second
  23. //--------------------------------------------------------------------------------------
  24. // Main game loop
  25. while (!WindowShouldClose()) // Detect window close button or ESC key
  26. {
  27. // Update
  28. //----------------------------------------------------------------------------------
  29. if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) start = GetMousePosition();
  30. else if (IsMouseButtonDown(MOUSE_RIGHT_BUTTON)) end = GetMousePosition();
  31. //----------------------------------------------------------------------------------
  32. // Draw
  33. //----------------------------------------------------------------------------------
  34. BeginDrawing();
  35. ClearBackground(RAYWHITE);
  36. DrawText("USE MOUSE LEFT-RIGHT CLICK to DEFINE LINE START and END POINTS", 15, 20, 20, GRAY);
  37. DrawLineBezier(start, end, 2.0f, RED);
  38. EndDrawing();
  39. //----------------------------------------------------------------------------------
  40. }
  41. // De-Initialization
  42. //--------------------------------------------------------------------------------------
  43. CloseWindow(); // Close window and OpenGL context
  44. //--------------------------------------------------------------------------------------
  45. return 0;
  46. }