Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[shapes] Add shapes_rectangle_advanced example implementing a DrawRectangleRoundedGradientH function #4435

Merged
merged 2 commits into from
Oct 29, 2024

Conversation

evertonse
Copy link
Contributor

@evertonse evertonse commented Oct 25, 2024

Edit: Add the shapes_rectangle_advanced examples that implements DrawRectangleRoundedGradientH as sugested.

Show Case:

Showcase Image

Tried to follow all convetions I could find for implementing an example.

@raysan5
Copy link
Owner

raysan5 commented Oct 26, 2024

@evertonse Thanks for the improvement but I'm afraid I'm not adding this function to raylib API, users with that level of requirement should implement the function on their end instead. There are too many possibilities for a rectangle to cover all requirements:

  • Border, border width, border color
  • Rounded corners, every one with independent value
  • Gradient, vertical/horizontal/specific-angle, multi-color
  • Corner vertex color with interpolation
  • Internal padding

A function to cover all those possibilities would require too many parameters and to keep adding more and more functions, I don't think it is the best approach for raylib.

But, you can provide a shapes_rectangle_advanced example implementing this custom function using rlgl. It would be very useful for users with those advance rectangle drawing rectangles to have a reference implementation and learn how to do it on their end.

@evertonse evertonse changed the title [rshapes] Add DrawRectangleRoundedGradientH function [shapes] Add shapes_rectangle_advanced example implementing a DrawRectangleRoundedGradientH function Oct 28, 2024
@evertonse
Copy link
Contributor Author

evertonse commented Oct 28, 2024

But you can provide a shapes_rectangle_advanced example implementing this custom function using rlgl. It would be very useful for users with those advanced rectangle drawing capabilities to have a reference implementation and learn how to do it on their end.

Thank you for the quick response, Raysan. I've done just that and updated the PR to accommodate it (update the numbers of examples on README, and makefiles). Let me know if you need any further adjustments.

Can I ask something? Would you be willing to accept a PR for getting an image from the clipboard that only works for Windows? I have implemented something like this:

// The user would have to call free on the pointer if the clipboard is not an image; it returns NULL.
char* pixels = GetClipboardImage(&width, &height, &data_size);
img = LoadImageFromMemory(".bmp", pixels, data_size);

I can easily change it into this:

Image image = GetClipboardImage();

The problem is that I don't have enough knowledge to make it work on X11 or Wayland, just for Windows. I also don't know the philosophy of the raylib project regarding having a function that only works for a single platform. I was thinking that maybe someone else could implement it for more platforms in an incremental way.


@raysan5
Copy link
Owner

raysan5 commented Oct 29, 2024

@evertonse Thank you very much for the review and all the work put on it! Sorry for not mentioning it earlier but would you mind making the example be 800x450 resolution, all raylib examples follow that same size to better fit in the web.

About the GetClipboardImage(), I'd love to have that function, together with SetClipboardImage(Image image) but that functionality should be provided by GLFW library... afaik, SDL already provides it...

Probably the function should be Image GetClipboardImage()... despite it couples rcore with rtext module...

In any case, feel free to send a PR for further review.

@raysan5 raysan5 merged commit ad79d4a into raysan5:master Oct 29, 2024
@raysan5
Copy link
Owner

raysan5 commented Oct 29, 2024

@evertonse thank you very much for this great example! 😄

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