From cdda4c4182c9ee068567529715e4a5c68a8efb58 Mon Sep 17 00:00:00 2001 From: bonmas14 Date: Sat, 20 Sep 2025 22:28:15 +0300 Subject: Init commit v1.0 --- deps/raylib/examples/shapes/shapes_lines_bezier.c | 85 +++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 deps/raylib/examples/shapes/shapes_lines_bezier.c (limited to 'deps/raylib/examples/shapes/shapes_lines_bezier.c') diff --git a/deps/raylib/examples/shapes/shapes_lines_bezier.c b/deps/raylib/examples/shapes/shapes_lines_bezier.c new file mode 100644 index 0000000..1293e16 --- /dev/null +++ b/deps/raylib/examples/shapes/shapes_lines_bezier.c @@ -0,0 +1,85 @@ +/******************************************************************************************* +* +* raylib [shapes] example - Cubic-bezier lines +* +* Example originally created with raylib 1.7, last time updated with raylib 1.7 +* +* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified, +* BSD-like license that allows static linking with closed source software +* +* Copyright (c) 2017-2024 Ramon Santamaria (@raysan5) +* +********************************************************************************************/ + +#include "raylib.h" + +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ +int main(void) +{ + // Initialization + //-------------------------------------------------------------------------------------- + const int screenWidth = 800; + const int screenHeight = 450; + + SetConfigFlags(FLAG_MSAA_4X_HINT); + InitWindow(screenWidth, screenHeight, "raylib [shapes] example - cubic-bezier lines"); + + Vector2 startPoint = { 30, 30 }; + Vector2 endPoint = { (float)screenWidth - 30, (float)screenHeight - 30 }; + bool moveStartPoint = false; + bool moveEndPoint = false; + + SetTargetFPS(60); // Set our game to run at 60 frames-per-second + //-------------------------------------------------------------------------------------- + + // Main game loop + while (!WindowShouldClose()) // Detect window close button or ESC key + { + // Update + //---------------------------------------------------------------------------------- + Vector2 mouse = GetMousePosition(); + + if (CheckCollisionPointCircle(mouse, startPoint, 10.0f) && IsMouseButtonDown(MOUSE_BUTTON_LEFT)) moveStartPoint = true; + else if (CheckCollisionPointCircle(mouse, endPoint, 10.0f) && IsMouseButtonDown(MOUSE_BUTTON_LEFT)) moveEndPoint = true; + + if (moveStartPoint) + { + startPoint = mouse; + if (IsMouseButtonReleased(MOUSE_BUTTON_LEFT)) moveStartPoint = false; + } + + if (moveEndPoint) + { + endPoint = mouse; + if (IsMouseButtonReleased(MOUSE_BUTTON_LEFT)) moveEndPoint = false; + } + //---------------------------------------------------------------------------------- + + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); + + ClearBackground(RAYWHITE); + + DrawText("MOVE START-END POINTS WITH MOUSE", 15, 20, 20, GRAY); + + // Draw line Cubic Bezier, in-out interpolation (easing), no control points + DrawLineBezier(startPoint, endPoint, 4.0f, BLUE); + + // Draw start-end spline circles with some details + DrawCircleV(startPoint, CheckCollisionPointCircle(mouse, startPoint, 10.0f)? 14.0f : 8.0f, moveStartPoint? RED : BLUE); + DrawCircleV(endPoint, CheckCollisionPointCircle(mouse, endPoint, 10.0f)? 14.0f : 8.0f, moveEndPoint? RED : BLUE); + + EndDrawing(); + //---------------------------------------------------------------------------------- + } + + // De-Initialization + //-------------------------------------------------------------------------------------- + CloseWindow(); // Close window and OpenGL context + //-------------------------------------------------------------------------------------- + + return 0; +} -- cgit v1.2.3-70-g09d2