Here is the code (as a function):

#define POINTS 10

sf::Shape& RoundedRectangle(float x, float y, float rectWidth, float rectHeight, float radius, const sf::Color& Col, float Outline, const sf::Color& OutlineCol)

{

sf::Shape* rrect=new sf::Shape();

rrect->SetOutlineWidth(Outline);

float X=0,Y=0;

for(int i=0; i<POINTS; i++)

{

X+=radius/POINTS;

Y=sqrt(radius*radius-X*X);

rrect->AddPoint(X+x+rectWidth-radius,y-Y+radius,Col,OutlineCol);

}

Y=0;

for(int i=0; i<POINTS; i++)

{

Y+=radius/POINTS;

X=sqrt(radius*radius-Y*Y);

rrect->AddPoint(x+rectWidth+X-radius,y+rectHeight-radius+Y,Col,OutlineCol);

}

X=0;

for(int i=0; i<POINTS; i++)

{

X+=radius/POINTS;

Y=sqrt(radius*radius-X*X);

rrect->AddPoint(x+radius-X,y+rectHeight-radius+Y,Col,OutlineCol);

}

Y=0;

for(int i=0; i<POINTS; i++)

{

Y+=radius/POINTS;

X=sqrt(radius*radius-Y*Y);

rrect->AddPoint(x-X+radius,y+radius-Y,Col,OutlineCol);

}

return *rrect;

}

I don't know if it was the most efficient way to go about doing this, but this is how my mind worked when I was coding it. If there is a way to make this code in any way better, I'd like to know; I'm fairly new to C++ (coming from Java). Anyone is free to use this code, modify it, etc.