Skip to content

[examples] Added shapes_recursive_tree#5229

Merged
raysan5 merged 7 commits into
raysan5:masterfrom
Jopestpe:master
Oct 6, 2025
Merged

[examples] Added shapes_recursive_tree#5229
raysan5 merged 7 commits into
raysan5:masterfrom
Jopestpe:master

Conversation

@Jopestpe
Copy link
Copy Markdown
Contributor

@Jopestpe Jopestpe commented Oct 2, 2025

Description

  • Adds a basic recursive tree example with GUI controls, showing:
  • Recursive branching with adjustable angle, thickness, and decay
  • Optional Bezier-style branches
  • Real-time modification via GUI sliders and checkbox

Changelog

  • Added examples/shapes/shapes_recursive_tree.c - example code
  • Added examples/shapes/shapes_recursive_tree.png - screenshot
  • Updated Makefile, README.md, and examples_list.txt

Tested and compiles successfully on Linux
shapes_recursive_tree

Comment thread examples/shapes/shapes_recursive_tree.c Outdated
@raysan5 raysan5 changed the title ADDED: example: shapes_recursive_tree [examples] Add shapes_recursive_tree Oct 2, 2025
@raysan5 raysan5 changed the title [examples] Add shapes_recursive_tree [examples] Added shapes_recursive_tree Oct 5, 2025
Comment thread examples/shapes/shapes_recursive_tree.c Outdated
Vector2 initialEnd = CalculateBranchEnd(start, 0.0f, length);
branches[count++] = (Branch){start, initialEnd, 0.0f, length};

for (int i = 0; i < count; i++) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, could you review it to follow raylib code conventions with aligned brackets?

Comment thread examples/shapes/shapes_recursive_tree.c Outdated

float nextLength = branch.length * branchDecay;

if (count < maxBranches && nextLength >= 2) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, could you review it to follow raylib code conventions with aligned brackets?

Comment thread examples/shapes/shapes_recursive_tree.c Outdated

ClearBackground(RAYWHITE);

for (int i = 0; i < count; i++) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, could you review it to follow raylib code conventions with aligned brackets?

Comment thread examples/shapes/shapes_recursive_tree.c Outdated
return 0;
}

static Vector2 CalculateBranchEnd(Vector2 start, float angle, float length) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, could you review it to follow raylib code conventions with aligned brackets?

Comment thread examples/shapes/shapes_recursive_tree.c Outdated

InitWindow(screenWidth, screenHeight, "raylib [shapes] example - shapes recursive tree");

Vector2 start = { (screenWidth / 2.0f) - 125, screenHeight };
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, could you review to follow raylib code conventions?

Comment thread examples/shapes/shapes_recursive_tree.c Outdated
{
// Update
//----------------------------------------------------------------------------------
float theta = angle * DEG2RAD;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, could you review to follow raylib code conventions?

Comment thread examples/shapes/shapes_recursive_tree.c Outdated

static Vector2 CalculateBranchEnd(Vector2 start, float angle, float length) {
return (Vector2){
start.x + length * sinf(angle),
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, could you review to follow raylib code conventions?

@raysan5
Copy link
Copy Markdown
Owner

raysan5 commented Oct 6, 2025

@Jopestpe Looks very good, just reviewed some minor format tweaks, to follow raylib code conventions. Thanks!

@Jopestpe
Copy link
Copy Markdown
Contributor Author

Jopestpe commented Oct 6, 2025

I think nothing will escape the conventions now 😅

@raysan5 raysan5 merged commit b99a6cc into raysan5:master Oct 6, 2025
16 checks passed
@raysan5
Copy link
Copy Markdown
Owner

raysan5 commented Oct 6, 2025

@Jopestpe great! thanks! 👍😄

sakgoyal pushed a commit to sakgoyal/raylib that referenced this pull request Oct 9, 2025
* ADDED: example: shapes_recursive_tree

* [examples] Added shapes_recursive_tree

* [examples] shapes_recursive_tree: adjustments

* Reduced tree depth from 12 to 10

* new shapes_recursive_tree.png

* follow the conventions

* follow the conventions 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants