Rounded rectangles & superellipse-based squircle for the SFML library
This library provides 2 sf::Drawable
objects: crd::RoundRect
and crd::Squircle
.
The APIs used are almost identical to SFML's RectangleShape except for a few differences:
#include <Cornered/RoundRect.hpp>
#include <Cornered/Squircle.hpp>
crd::RoundRect my_rectangle({100.f, 100.f}, 10.f); // Rounded rectangle, 100x100, with radius 10 corners
assert(my_rectangle.getRadius() == 10.f); // get corner radius
my_rectangle.setRadius(20.f); // set corner radius to 20
crd::Squircle my_squircle(50.f); // Squircle with radius 50
my_squircle.setResolution(50); // increase the resolution of the squircle - more points, smoother curves
my_squircle.setN(5.f);
The n
-value of the squircles defines its shape. Find out more here.
If you're using the CMake (eg through the official sfml template), you can also use it for this repo!
Simply add the following to your CMakeLists.txt
file:
FetchContent_Declare(Cornered
GIT_REPOSITORY https://github.com/metaquarx/Cornered.git
GIT_TAG 1.0.0)
FetchContent_MakeAvailable(Cornered)
target_link_libraries(YOUR_PROJECT_NAME PRIVATE Cornered)