Git Product home page Git Product logo

cornered's Introduction

Cornered

Rounded rectangles & superellipse-based squircle for the SFML library

A screenshot showing the shape difference between a rounded square and a squircle

Usage

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.

Adding to your project

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)

cornered's People

Contributors

metaquarx avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

cornered's Issues

Shape with any number of vertices and rounded corners

Hello, I see that you are really good at creating such libraries. I want to create a class that will allow to create shapes with any number of vertices and do rounding of each vertex. I already have some implementation using sf::ConvexShape, but I have encountered a problem with the Origin installation and also the class itself is made crookedly, one function may entail calling other functions to preserve the size, position and other properties of the shape. Could you please share the subtleties of working with sf::Shape class, I don't quite understand how you realized rounding using getPoint() function. Thanks in advance for any information on this issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.