From ffdce81678775b324d44224e9f11d0014bcf8e18 Mon Sep 17 00:00:00 2001 From: cmanlh Date: Wed, 30 Oct 2024 20:27:03 +0800 Subject: [PATCH] Add example for draw ellipse --- examples/Makefile | 3 +- examples/shapes/shapes_draw_ellipse.c | 84 ++++++++++++++++++++++++ examples/shapes/shapes_draw_ellipse.png | Bin 0 -> 9022 bytes 3 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 examples/shapes/shapes_draw_ellipse.c create mode 100644 examples/shapes/shapes_draw_ellipse.png diff --git a/examples/Makefile b/examples/Makefile index a3ce8f6d..5a84bec6 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -533,7 +533,8 @@ SHAPES = \ shapes/shapes_rectangle_scaling \ shapes/shapes_splines_drawing \ shapes/shapes_top_down_lights \ - shapes/shapes_rectangle_advanced + shapes/shapes_rectangle_advanced \ + shapes/shapes_draw_ellipse TEXTURES = \ textures/textures_background_scrolling \ diff --git a/examples/shapes/shapes_draw_ellipse.c b/examples/shapes/shapes_draw_ellipse.c new file mode 100644 index 00000000..70d948c3 --- /dev/null +++ b/examples/shapes/shapes_draw_ellipse.c @@ -0,0 +1,84 @@ +/******************************************************************************************* + * + * raylib [shapes] example - draw ellipse + * + * Example originally created with raylib 4.2, last time updated with raylib 5.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) 2022-2024 Lu Hong (@CManLH) + * + ********************************************************************************************/ + +#include "raylib.h" + +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ +int main(void) +{ + // Initialization + //-------------------------------------------------------------------------------------- + const int screenWidth = 800; + const int screenHeight = 450; + + InitWindow(screenWidth, screenHeight, "raylib [shapes] example - draw ellipse"); + + float radiusH = 70.0f; + float radiusV = 100.0f; + + Vector2 ellipseCenter = (Vector2){200, 100}; + Color ellipseColor = SKYBLUE; + + Vector2 ellipseLineCenter = (Vector2){200, 325}; + Color ellipseLineColor = DARKGREEN; + + Vector2 rotationEllipseCenter = (Vector2){460, 100}; + Color rotationEllipseColor = GREEN; + + Vector2 rotationEllipseLineCenter = (Vector2){460, 325}; + Color rotationEllipseLineColor = RED; + + float angle = PI / 6.0f; + + SetTargetFPS(60); // Set our game to run at 60 frames-per-second + //-------------------------------------------------------------------------------------- + + // Main game loop + while (!WindowShouldClose()) // Detect window close button or ESC key + { + + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); + + ClearBackground(RAYWHITE); + + // Draw ellipse + DrawEllipse(ellipseCenter.x, ellipseCenter.y, radiusH, radiusV, ellipseColor); + DrawText("Ellipse!", ellipseCenter.x - 35, ellipseCenter.y, 20, BLACK); + + // Draw ellipse outline + DrawEllipseLines(ellipseLineCenter.x, ellipseLineCenter.y, radiusH, radiusV, ellipseLineColor); + DrawText("Ellipse Outline", ellipseLineCenter.x - radiusH, ellipseLineCenter.y, 20, BLACK); + + // Draw ellipse with rotation + DrawEllipseRotation(rotationEllipseCenter.x, rotationEllipseCenter.y, radiusH, radiusV, rotationEllipseColor, angle); + DrawText("Rotation Ellipse", rotationEllipseCenter.x - radiusH - 35, rotationEllipseCenter.y, 20, BLACK); + + // Draw ellipse outline with rotation + DrawEllipseLinesRotation(rotationEllipseLineCenter.x, rotationEllipseLineCenter.y, radiusH, radiusV, rotationEllipseLineColor, angle); + DrawText("Rotation Ellipse outline", rotationEllipseLineCenter.x - radiusH - 35, rotationEllipseLineCenter.y, 20, BLACK); + + EndDrawing(); + //---------------------------------------------------------------------------------- + } + + CloseWindow(); // Close window and OpenGL context + //-------------------------------------------------------------------------------------- + + return 0; +} \ No newline at end of file diff --git a/examples/shapes/shapes_draw_ellipse.png b/examples/shapes/shapes_draw_ellipse.png new file mode 100644 index 0000000000000000000000000000000000000000..de0608c8e3ad6d260cae61d79850df55106148ce GIT binary patch literal 9022 zcmc(FcT`i^{%@!PDm4~{CVeu1fElF(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