62f1511e5f
Some examples included in this batch require the included libraries: `easings.h` and `raygui.h`. Examples included: - shapes_bouncing_ball - shapes_collision_area - shapes_following_eyes - shapes_draw_circle_sector (requires raygui.h) - shapes_draw_rectangle_rounded (requires raygui.h) - shapes_draw_ring (requires raygui.h) - shapes_easings_ball_anim (requires easings.h) - shapes_easings_box_anim (requires easings.h) - shapes_easings_rectangle_array (requires easings.h)
79 lines
3.4 KiB
C
79 lines
3.4 KiB
C
/*******************************************************************************************
|
|
*
|
|
* raylib [shapes] example - draw circle sector (with gui options)
|
|
*
|
|
* This example has been created using raylib 2.5 (www.raylib.com)
|
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
|
*
|
|
* Copyright (c) 2019 Vlad Adrian (@Demizdor) and Ramon Santamaria (@raysan5)
|
|
*
|
|
********************************************************************************************/
|
|
|
|
#include <raylib.h>
|
|
|
|
#define RAYGUI_IMPLEMENTATION
|
|
#include "raygui.h" // Required for GUI controls
|
|
|
|
int main()
|
|
{
|
|
// Initialization
|
|
//--------------------------------------------------------------------------------------
|
|
const int screenWidth = 800;
|
|
const int screenHeight = 450;
|
|
|
|
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - draw circle sector");
|
|
|
|
Vector2 center = {(GetScreenWidth() - 300)/2, GetScreenHeight()/2 };
|
|
|
|
float outerRadius = 180.f;
|
|
int startAngle = 0;
|
|
int endAngle = 180;
|
|
int segments = 0;
|
|
|
|
SetTargetFPS(60);
|
|
//--------------------------------------------------------------------------------------
|
|
|
|
// 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, segments, Fade(MAROON, 0.3));
|
|
DrawCircleSectorLines(center, outerRadius, startAngle, endAngle, segments, Fade(MAROON, 0.6));
|
|
|
|
// Draw GUI controls
|
|
//------------------------------------------------------------------------------
|
|
startAngle = GuiSliderBar((Rectangle){ 600, 40, 120, 20}, "StartAngle", startAngle, 0, 720, true );
|
|
endAngle = GuiSliderBar((Rectangle){ 600, 70, 120, 20}, "EndAngle", endAngle, 0, 720, true);
|
|
|
|
outerRadius = GuiSliderBar((Rectangle){ 600, 140, 120, 20}, "Radius", outerRadius, 0, 200, true);
|
|
segments = GuiSliderBar((Rectangle){ 600, 170, 120, 20}, "Segments", segments, 0, 100, true);
|
|
//------------------------------------------------------------------------------
|
|
|
|
DrawText(FormatText("MODE: %s", (segments >= 4)? "MANUAL" : "AUTO"), 600, 200, 10, (segments >= 4)? MAROON : DARKGRAY);
|
|
|
|
DrawFPS(10, 10);
|
|
|
|
EndDrawing();
|
|
//----------------------------------------------------------------------------------
|
|
}
|
|
|
|
// De-Initialization
|
|
//--------------------------------------------------------------------------------------
|
|
CloseWindow(); // Close window and OpenGL context
|
|
//--------------------------------------------------------------------------------------
|
|
|
|
return 0;
|
|
} |