summaryrefslogtreecommitdiffhomepage
path: root/examples/shapes/shapes_lines_bezier.c
diff options
context:
space:
mode:
authorRay <[email protected]>2023-09-08 13:27:13 +0200
committerRay <[email protected]>2023-09-08 13:27:13 +0200
commit1896268775e59d00b2b4f3fea0bc244eee1a1cb4 (patch)
treedd695865a0545a29d08901563d1b96c578814564 /examples/shapes/shapes_lines_bezier.c
parent2d5d0c2999717ea28924d6cdd47bab014478cc32 (diff)
downloadraylib-1896268775e59d00b2b4f3fea0bc244eee1a1cb4.tar.gz
raylib-1896268775e59d00b2b4f3fea0bc244eee1a1cb4.zip
Reviewed examples for consistency
Diffstat (limited to 'examples/shapes/shapes_lines_bezier.c')
-rw-r--r--examples/shapes/shapes_lines_bezier.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/examples/shapes/shapes_lines_bezier.c b/examples/shapes/shapes_lines_bezier.c
index 195281be..f0157685 100644
--- a/examples/shapes/shapes_lines_bezier.c
+++ b/examples/shapes/shapes_lines_bezier.c
@@ -28,6 +28,9 @@ int main(void)
Vector2 start = { 0, 0 };
Vector2 end = { (float)screenWidth, (float)screenHeight };
+
+ Vector2 startControl = { 100, 0 };
+ Vector2 endControl = { GetScreenWidth() - 100, GetScreenHeight() };
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
@@ -37,8 +40,16 @@ int main(void)
{
// Update
//----------------------------------------------------------------------------------
- if (IsMouseButtonDown(MOUSE_BUTTON_LEFT)) start = GetMousePosition();
- else if (IsMouseButtonDown(MOUSE_BUTTON_RIGHT)) end = GetMousePosition();
+ if (IsKeyDown(KEY_LEFT_CONTROL))
+ {
+ if (IsMouseButtonDown(MOUSE_BUTTON_LEFT)) startControl = GetMousePosition();
+ else if (IsMouseButtonDown(MOUSE_BUTTON_RIGHT)) endControl = GetMousePosition();
+ }
+ else
+ {
+ if (IsMouseButtonDown(MOUSE_BUTTON_LEFT)) start = GetMousePosition();
+ else if (IsMouseButtonDown(MOUSE_BUTTON_RIGHT)) end = GetMousePosition();
+ }
//----------------------------------------------------------------------------------
// Draw
@@ -49,7 +60,14 @@ int main(void)
DrawText("USE MOUSE LEFT-RIGHT CLICK to DEFINE LINE START and END POINTS", 15, 20, 20, GRAY);
- DrawLineBezier(start, end, 2.0f, RED);
+ //DrawLineBezier(start, end, 2.0f, RED);
+
+ DrawLineBezierCubic(start, end, startControl, endControl, 2.0f, RED);
+
+ DrawLineEx(start, startControl, 1.0, LIGHTGRAY);
+ DrawLineEx(end, endControl, 1.0, LIGHTGRAY);
+ DrawCircleV(startControl, 10, RED);
+ DrawCircleV(endControl, 10, RED);
EndDrawing();
//----------------------------------------------------------------------------------