# drawing trapezoid/parallelogram with rounded corners

This topic is 4419 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello folks I hope I'm here in the right forum. First of all: I was NEVER good in maths so I want to ask how to solve this special thing I try to draw a trapezoid or better parallelogram shaped rect. But not a nomal rect - it should have "rounded" corners. I have an ordinary rect function like rect(LEFT,TOP,RIGHT,BOTTOM); Since I don't want to use it for every single line of this shape and I would like to draw these trapezoids in different sizes I would like to ask: HOW could I solve this? To imagine - it should look like this (not so ugly, just for theory): http://www.dxx-rebirth.de/files/bleh.jpg If someone could make this a bit easier for me it would be VERY nice :)

##### Share on other sites
How are you rendering the graphics? Are you using a graphics API or library?

##### Share on other sites
yes
I'm doing a small game.

I'm using SDL and OpenGL for this.

[Edited by - zico on October 15, 2006 5:13:54 AM]

##### Share on other sites
You know the 4 corner points and you know the radii of at the 4 corners.

You'll need to find the center, start and end angle of the circle segments at the corners. This is the tricky part. Read up something on trigonometry. Once you have these values you can generate the vertices for the round edges with simple math.

Do this for all 4 corners in the same winding as you generate your arcs, and draw the outline as a triangle-fan. That works for all trapezoids and parallelograms.

##### Share on other sites
you could also create a usual rectangle with rounded corners and apply a shear to it. i think that would be easier but maybe a little slower.

regards,
m4gnus

1. 1
Rutin
44
2. 2
3. 3
4. 4
5. 5

• 10
• 28
• 20
• 9
• 20
• ### Forum Statistics

• Total Topics
633409
• Total Posts
3011702
• ### Who's Online (See full list)

There are no registered users currently online

×