From 1c0cc775732201f4c4d3ee0d6772be786b3b4aa1 Mon Sep 17 00:00:00 2001 From: Uneven Prankster Date: Sun, 15 Oct 2023 21:28:29 -0300 Subject: A lot has certainly happened! --- raylib/examples/shapes/shapes_draw_circle_sector.c | 88 ++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 raylib/examples/shapes/shapes_draw_circle_sector.c (limited to 'raylib/examples/shapes/shapes_draw_circle_sector.c') diff --git a/raylib/examples/shapes/shapes_draw_circle_sector.c b/raylib/examples/shapes/shapes_draw_circle_sector.c new file mode 100644 index 0000000..1c283e1 --- /dev/null +++ b/raylib/examples/shapes/shapes_draw_circle_sector.c @@ -0,0 +1,88 @@ +/******************************************************************************************* +* +* raylib [shapes] example - draw circle sector (with gui options) +* +* Example originally created with raylib 2.5, last time updated with raylib 2.5 +* +* Example contributed by Vlad Adrian (@demizdor) and reviewed by Ramon Santamaria (@raysan5) +* +* 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) 2018-2023 Vlad Adrian (@demizdor) and Ramon Santamaria (@raysan5) +* +********************************************************************************************/ + +#include + +#define RAYGUI_IMPLEMENTATION +#include "raygui.h" // Required for GUI controls + +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ +int main(void) +{ + // Initialization + //-------------------------------------------------------------------------------------- + const int screenWidth = 800; + const int screenHeight = 450; + + InitWindow(screenWidth, screenHeight, "raylib [shapes] example - draw circle sector"); + + Vector2 center = {(GetScreenWidth() - 300)/2.0f, GetScreenHeight()/2.0f }; + + float outerRadius = 180.0f; + float startAngle = 0.0f; + float endAngle = 180.0f; + float segments = 10.0f; + float minSegments = 4; + + 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 + //---------------------------------------------------------------------------------- + // NOTE: All variables update happens inside GUI control functions + //---------------------------------------------------------------------------------- + + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); + + ClearBackground(RAYWHITE); + + DrawLine(500, 0, 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.6f)); + DrawRectangle(500, 0, GetScreenWidth() - 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.3f)); + + DrawCircleSector(center, outerRadius, startAngle, endAngle, (int)segments, Fade(MAROON, 0.3f)); + DrawCircleSectorLines(center, outerRadius, startAngle, endAngle, (int)segments, Fade(MAROON, 0.6f)); + + // Draw GUI controls + //------------------------------------------------------------------------------ + GuiSliderBar((Rectangle){ 600, 40, 120, 20}, "StartAngle", NULL, &startAngle, 0, 720); + GuiSliderBar((Rectangle){ 600, 70, 120, 20}, "EndAngle", NULL, &endAngle, 0, 720); + + GuiSliderBar((Rectangle){ 600, 140, 120, 20}, "Radius", NULL, &outerRadius, 0, 200); + GuiSliderBar((Rectangle){ 600, 170, 120, 20}, "Segments", NULL, &segments, 0, 100); + //------------------------------------------------------------------------------ + + minSegments = (int)ceilf((endAngle - startAngle) / 90); + DrawText(TextFormat("MODE: %s", (segments >= minSegments)? "MANUAL" : "AUTO"), 600, 200, 10, (segments >= minSegments)? MAROON : DARKGRAY); + + DrawFPS(10, 10); + + EndDrawing(); + //---------------------------------------------------------------------------------- + } + + // De-Initialization + //-------------------------------------------------------------------------------------- + CloseWindow(); // Close window and OpenGL context + //-------------------------------------------------------------------------------------- + + return 0; +} \ No newline at end of file -- cgit v1.2.3