Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,7 @@ SHAPES = \
shapes/shapes_lines_bezier \
shapes/shapes_logo_raylib \
shapes/shapes_logo_raylib_anim \
shapes/shapes_math_angle_rotation \
shapes/shapes_rectangle_advanced \
shapes/shapes_rectangle_scaling \
shapes/shapes_ring_drawing \
Expand Down
4 changes: 4 additions & 0 deletions examples/Makefile.Web
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,7 @@ SHAPES = \
shapes/shapes_lines_bezier \
shapes/shapes_logo_raylib \
shapes/shapes_logo_raylib_anim \
shapes/shapes_math_angle_rotation \
shapes/shapes_rectangle_advanced \
shapes/shapes_rectangle_scaling \
shapes/shapes_ring_drawing \
Expand Down Expand Up @@ -862,6 +863,9 @@ shapes/shapes_logo_raylib: shapes/shapes_logo_raylib.c
shapes/shapes_logo_raylib_anim: shapes/shapes_logo_raylib_anim.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)

shapes/shapes_math_angle_rotation: shapes/shapes_math_angle_rotation.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)

shapes/shapes_rectangle_advanced: shapes/shapes_rectangle_advanced.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM)

Expand Down
5 changes: 3 additions & 2 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ You may find it easier to use than other toolchains, especially when it comes to
- `zig build [module]` to compile all examples for a module (e.g. `zig build core`)
- `zig build [example]` to compile _and run_ a particular example (e.g. `zig build core_basic_window`)

## EXAMPLES COLLECTION [TOTAL: 172]
## EXAMPLES COLLECTION [TOTAL: 173]

### category: core [40]

Expand Down Expand Up @@ -66,7 +66,7 @@ Examples using raylib[core](../src/rcore.c) platform functionality like window c
| [core_undo_redo](core/core_undo_redo.c) | <img src="core/core_undo_redo.png" alt="core_undo_redo" width="80"> | ⭐⭐⭐☆ | 5.5 | 5.6 | [Ramon Santamaria](https://github.com/raysan5) |
| [core_input_actions](core/core_input_actions.c) | <img src="core/core_input_actions.png" alt="core_input_actions" width="80"> | ⭐⭐☆☆ | 5.5 | 5.6 | [Jett](https://github.com/JettMonstersGoBoom) |

### category: shapes [23]
### category: shapes [24]

Examples using raylib shapes drawing functionality, provided by raylib [shapes](../src/rshapes.c) module.

Expand Down Expand Up @@ -95,6 +95,7 @@ Examples using raylib shapes drawing functionality, provided by raylib [shapes](
| [shapes_double_pendulum](shapes/shapes_double_pendulum.c) | <img src="shapes/shapes_double_pendulum.png" alt="shapes_double_pendulum" width="80"> | ⭐⭐☆☆ | 5.5 | 5.5 | [JoeCheong](https://github.com/Joecheong2006) |
| [shapes_dashed_line](shapes/shapes_dashed_line.c) | <img src="shapes/shapes_dashed_line.png" alt="shapes_dashed_line" width="80"> | ⭐☆☆☆ | 5.5 | 5.5 | [Luís Almeida](https://github.com/luis605) |
| [shapes_vector_angle](shapes/shapes_vector_angle.c) | <img src="shapes/shapes_vector_angle.png" alt="shapes_vector_angle" width="80"> | ⭐⭐☆☆ | 1.0 | 5.0 | [Ramon Santamaria](https://github.com/raysan5) |
| [shapes_math_angle_rotation](shapes/shapes_math_angle_rotation.c) | <img src="shapes/shapes_math_angle_rotation.png" alt="shapes_math_angle_rotation" width="80"> | ⭐☆☆☆ | 5.5 | 5.6 | [Kris](https://github.com/krispy-snacc) |

### category: textures [26]

Expand Down
1 change: 1 addition & 0 deletions examples/examples_list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ shapes;shapes_digital_clock;★★★★;5.5;5.6;2025;2025;"Hamza RAHAL";@hmz-rh
shapes;shapes_double_pendulum;★★☆☆;5.5;5.5;2025;2025;"JoeCheong";@Joecheong2006
shapes;shapes_dashed_line;★☆☆☆;5.5;5.5;2025;2025;"Luís Almeida";@luis605
shapes;shapes_vector_angle;★★☆☆;1.0;5.0;2023;2025;"Ramon Santamaria";@raysan5
shapes;shapes_math_angle_rotation;★☆☆☆;5.5;5.6;0;0;"Kris";@krispy-snacc
textures;textures_logo_raylib;★☆☆☆;1.0;1.0;2014;2025;"Ramon Santamaria";@raysan5
textures;textures_srcrec_dstrec;★★★☆;1.3;1.3;2015;2025;"Ramon Santamaria";@raysan5
textures;textures_image_drawing;★★☆☆;1.4;1.4;2016;2025;"Ramon Santamaria";@raysan5
Expand Down
4 changes: 2 additions & 2 deletions examples/shaders/shaders_palette_switch.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************************
*
* raylib [shaders] example - palette switch
* raylib [shaders] example - palette switch
*
* Example complexity rating: [★★★☆] 3/4
*
Expand All @@ -11,7 +11,7 @@
* on OpenGL ES 2.0 platforms (Android, Raspberry Pi, HTML5), use #version 100 shaders
* raylib comes with shaders ready for both versions, check raylib/shaders install folder
*
* Example originally created with raylib 2.5, last time updated with raylib 3.7
* Example originally created with raylib 2.5, last time updated with raylib 3.7
*
* Example contributed by Marco Lizza (@MarcoLizza) and reviewed by Ramon Santamaria (@raysan5)
*
Expand Down
102 changes: 102 additions & 0 deletions examples/shapes/shapes_math_angle_rotation.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*******************************************************************************************
*
* raylib [shapes] example - Math angle rotation lines
*
* Example complexity rating: [★☆☆☆] 1/4
*
* Example originally created with raylib 5.5, last time updated with raylib 5.6
*
* Example contributed by Kris (@krispy-snacc) and reviewed by Ramon Santamaria (@raysan5)
*
* Example licensed under an unmodified zlib/libpng license
*
********************************************************************************************/

#include "raylib.h"
#include "raymath.h" // for DEG2RAD

//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
int main(void)
{
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 720;
const int screenHeight = 400;

InitWindow(screenWidth, screenHeight, "raylib [shapes] example - angle rotation lines");
SetTargetFPS(60);

Vector2 center = { screenWidth / 2.0f, screenHeight / 2.0f };
const float lineLength = 150.0f;

// Predefined angles for fixed lines
int angles[] = { 0, 30, 60, 90 };
int numAngles = sizeof(angles)/sizeof(angles[0]);

float totalAngle = 0.0f; // Animated rotation angle
//--------------------------------------------------------------------------------------

// Main game loop
while (!WindowShouldClose())
{
// Update
//----------------------------------------------------------------------------------
totalAngle += 1.0f; // degrees per frame
if (totalAngle >= 360.0f) totalAngle -= 360.0f;
//----------------------------------------------------------------------------------

// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(WHITE);

DrawText("Fixed angles + rotating line", 10, 10, 20, LIGHTGRAY);

// Draw fixed-angle lines with colorful gradient
for (int i = 0; i < numAngles; i++)
{
float rad = angles[i] * DEG2RAD;
Vector2 end = { center.x + cosf(rad) * lineLength,
center.y + sinf(rad) * lineLength };

// Gradient color from green → cyan → blue → magenta
Color col;
switch(i)
{
case 0: col = GREEN; break;
case 1: col = ORANGE; break;
case 2: col = BLUE; break;
case 3: col = MAGENTA; break;
default: col = WHITE; break;
}

DrawLineEx(center, end, 5.0f, col);

// Draw angle label slightly offset along the line
Vector2 textPos = { center.x + cosf(rad) * (lineLength + 20),
center.y + sinf(rad) * (lineLength + 20) };
DrawText(TextFormat("%d°", angles[i]), (int)textPos.x, (int)textPos.y, 20, col);
}

// Draw animated rotating line with changing color
float animRad = totalAngle * DEG2RAD;
Vector2 animEnd = { center.x + cosf(animRad) * lineLength,
center.y + sinf(animRad) * lineLength };

// Cycle through HSV colors for animated line
Color animCol = ColorFromHSV(fmodf(totalAngle, 360.0f), 0.8f, 0.9f);
DrawLineEx(center, animEnd, 5.0f, animCol);

EndDrawing();
//----------------------------------------------------------------------------------
}

// De-Initialization
//--------------------------------------------------------------------------------------
CloseWindow();
//--------------------------------------------------------------------------------------

return 0;
}
Binary file added examples/shapes/shapes_math_angle_rotation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading