瀏覽代碼

Updated examples to `raygui 4.0-dev`

pull/3103/head
Ray 1 年之前
父節點
當前提交
6aada7d5ec
共有 4 個檔案被更改,包括 1650 行新增1197 行删除
  1. +1615
    -1162
      examples/shapes/raygui.h
  2. +8
    -8
      examples/shapes/shapes_draw_circle_sector.c
  3. +15
    -15
      examples/shapes/shapes_draw_rectangle_rounded.c
  4. +12
    -12
      examples/shapes/shapes_draw_ring.c

+ 1615
- 1162
examples/shapes/raygui.h
文件差異過大導致無法顯示
查看文件


+ 8
- 8
examples/shapes/shapes_draw_circle_sector.c 查看文件

@ -35,8 +35,8 @@ int main(void)
float outerRadius = 180.0f;
float startAngle = 0.0f;
float endAngle = 180.0f;
int segments = 0;
int minSegments = 4;
float segments = 10.0f;
float minSegments = 4;
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
@ -58,16 +58,16 @@ int main(void)
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.3f));
DrawCircleSectorLines(center, outerRadius, startAngle, endAngle, segments, Fade(MAROON, 0.6f));
DrawCircleSector(center, outerRadius, startAngle, endAngle, p">(int)segments, Fade(MAROON, 0.3f));
DrawCircleSectorLines(center, outerRadius, startAngle, endAngle, p">(int)segments, Fade(MAROON, 0.6f));
// Draw GUI controls
//------------------------------------------------------------------------------
startAngle = GuiSliderBar((Rectangle){ 600, 40, 120, 20}, "StartAngle", NULL, startAngle, 0, 720);
endAngle = GuiSliderBar((Rectangle){ 600, 70, 120, 20}, "EndAngle", NULL, endAngle, 0, 720);
GuiSliderBar((Rectangle){ 600, 40, 120, 20}, "StartAngle", NULL, &startAngle, 0, 720);
GuiSliderBar((Rectangle){ 600, 70, 120, 20}, "EndAngle", NULL, &endAngle, 0, 720);
outerRadius = GuiSliderBar((Rectangle){ 600, 140, 120, 20}, "Radius", NULL, outerRadius, 0, 200);
segments = (int)GuiSliderBar((Rectangle){ 600, 170, 120, 20}, "Segments", NULL, p">(float)segments, 0, 100);
GuiSliderBar((Rectangle){ 600, 140, 120, 20}, "Radius", NULL, &outerRadius, 0, 200);
GuiSliderBar((Rectangle){ 600, 170, 120, 20}, "Segments", NULL, o">&segments, 0, 100);
//------------------------------------------------------------------------------
minSegments = (int)ceilf((endAngle - startAngle) / 90);

+ 15
- 15
examples/shapes/shapes_draw_rectangle_rounded.c 查看文件

@ -31,10 +31,10 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - draw rectangle rounded");
float roundness = 0.2f;
int width = 200;
int height = 100;
int segments = 0;
int lineThick = 1;
float width = 200.0f;
float height = 100.0f;
float segments = 0.0f;
float lineThick = 1.0f;
bool drawRect = false;
bool drawRoundedRect = true;
@ -61,20 +61,20 @@ int main(void)
DrawRectangle(560, 0, GetScreenWidth() - 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.3f));
if (drawRect) DrawRectangleRec(rec, Fade(GOLD, 0.6f));
if (drawRoundedRect) DrawRectangleRounded(rec, roundness, segments, Fade(MAROON, 0.2f));
if (drawRoundedLines) DrawRectangleRoundedLines(rec,roundness, n">segments, (float)lineThick, Fade(MAROON, 0.4f));
if (drawRoundedRect) DrawRectangleRounded(rec, roundness, p">(int)segments, Fade(MAROON, 0.2f));
if (drawRoundedLines) DrawRectangleRoundedLines(rec, roundness, p">(int)segments, lineThick, Fade(MAROON, 0.4f));
// Draw GUI controls
//------------------------------------------------------------------------------
width = (int)GuiSliderBar((Rectangle){ 640, 40, 105, 20 }, "Width", NULL, p">(float)width, 0, (float)GetScreenWidth() - 300);
height = (int)GuiSliderBar((Rectangle){ 640, 70, 105, 20 }, "Height", NULL, p">(float)height, 0, (float)GetScreenHeight() - 50);
roundness = GuiSliderBar((Rectangle){ 640, 140, 105, 20 }, "Roundness", NULL, roundness, 0.0f, 1.0f);
lineThick = (int)GuiSliderBar((Rectangle){ 640, 170, 105, 20 }, "Thickness", NULL, p">(float)lineThick, 0, 20);
segments = (int)GuiSliderBar((Rectangle){ 640, 240, 105, 20}, "Segments", NULL, p">(float)segments, 0, 60);
drawRoundedRect = GuiCheckBox((Rectangle){ 640, 320, 20, 20 }, "DrawRoundedRect", drawRoundedRect);
drawRoundedLines = GuiCheckBox((Rectangle){ 640, 350, 20, 20 }, "DrawRoundedLines", drawRoundedLines);
drawRect = GuiCheckBox((Rectangle){ 640, 380, 20, 20}, "DrawRect", drawRect);
GuiSliderBar((Rectangle){ 640, 40, 105, 20 }, "Width", NULL, o">&width, 0, (float)GetScreenWidth() - 300);
GuiSliderBar((Rectangle){ 640, 70, 105, 20 }, "Height", NULL, o">&height, 0, (float)GetScreenHeight() - 50);
GuiSliderBar((Rectangle){ 640, 140, 105, 20 }, "Roundness", NULL, &roundness, 0.0f, 1.0f);
GuiSliderBar((Rectangle){ 640, 170, 105, 20 }, "Thickness", NULL, o">&lineThick, 0, 20);
GuiSliderBar((Rectangle){ 640, 240, 105, 20}, "Segments", NULL, o">&segments, 0, 60);
GuiCheckBox((Rectangle){ 640, 320, 20, 20 }, "DrawRoundedRect", &drawRoundedRect);
GuiCheckBox((Rectangle){ 640, 350, 20, 20 }, "DrawRoundedLines", &drawRoundedLines);
GuiCheckBox((Rectangle){ 640, 380, 20, 20}, "DrawRect", &drawRect);
//------------------------------------------------------------------------------
DrawText(TextFormat("MODE: %s", (segments >= 4)? "MANUAL" : "AUTO"), 640, 280, 10, (segments >= 4)? MAROON : DARKGRAY);

+ 12
- 12
examples/shapes/shapes_draw_ring.c 查看文件

@ -37,7 +37,7 @@ int main(void)
float startAngle = 0.0f;
float endAngle = 360.0f;
int segments = 0;
float segments = 0.0f;
bool drawRing = true;
bool drawRingLines = false;
@ -63,23 +63,23 @@ int main(void)
DrawLine(500, 0, 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.6f));
DrawRectangle(500, 0, GetScreenWidth() - 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.3f));
if (drawRing) DrawRing(center, innerRadius, outerRadius, startAngle, endAngle, segments, Fade(MAROON, 0.3f));
if (drawRingLines) DrawRingLines(center, innerRadius, outerRadius, startAngle, endAngle, segments, Fade(BLACK, 0.4f));
if (drawCircleLines) DrawCircleSectorLines(center, outerRadius, startAngle, endAngle, segments, Fade(BLACK, 0.4f));
if (drawRing) DrawRing(center, innerRadius, outerRadius, startAngle, endAngle, p">(int)segments, Fade(MAROON, 0.3f));
if (drawRingLines) DrawRingLines(center, innerRadius, outerRadius, startAngle, endAngle, p">(int)segments, Fade(BLACK, 0.4f));
if (drawCircleLines) DrawCircleSectorLines(center, outerRadius, startAngle, endAngle, p">(int)segments, Fade(BLACK, 0.4f));
// Draw GUI controls
//------------------------------------------------------------------------------
startAngle = GuiSliderBar((Rectangle){ 600, 40, 120, 20 }, "StartAngle", NULL, startAngle, -450, 450);
endAngle = GuiSliderBar((Rectangle){ 600, 70, 120, 20 }, "EndAngle", NULL, endAngle, -450, 450);
GuiSliderBar((Rectangle){ 600, 40, 120, 20 }, "StartAngle", NULL, &startAngle, -450, 450);
GuiSliderBar((Rectangle){ 600, 70, 120, 20 }, "EndAngle", NULL, &endAngle, -450, 450);
innerRadius = GuiSliderBar((Rectangle){ 600, 140, 120, 20 }, "InnerRadius", NULL, innerRadius, 0, 100);
outerRadius = GuiSliderBar((Rectangle){ 600, 170, 120, 20 }, "OuterRadius", NULL, outerRadius, 0, 200);
GuiSliderBar((Rectangle){ 600, 140, 120, 20 }, "InnerRadius", NULL, &innerRadius, 0, 100);
GuiSliderBar((Rectangle){ 600, 170, 120, 20 }, "OuterRadius", NULL, &outerRadius, 0, 200);
segments = (int)GuiSliderBar((Rectangle){ 600, 240, 120, 20 }, "Segments", NULL, p">(float)segments, 0, 100);
GuiSliderBar((Rectangle){ 600, 240, 120, 20 }, "Segments", NULL, o">&segments, 0, 100);
drawRing = GuiCheckBox((Rectangle){ 600, 320, 20, 20 }, "Draw Ring", drawRing);
drawRingLines = GuiCheckBox((Rectangle){ 600, 350, 20, 20 }, "Draw RingLines", drawRingLines);
drawCircleLines = GuiCheckBox((Rectangle){ 600, 380, 20, 20 }, "Draw CircleLines", drawCircleLines);
GuiCheckBox((Rectangle){ 600, 320, 20, 20 }, "Draw Ring", &drawRing);
GuiCheckBox((Rectangle){ 600, 350, 20, 20 }, "Draw RingLines", &drawRingLines);
GuiCheckBox((Rectangle){ 600, 380, 20, 20 }, "Draw CircleLines", &drawCircleLines);
//------------------------------------------------------------------------------
int minSegments = (int)ceilf((endAngle - startAngle)/90);

Loading…
取消
儲存