• Advertisement
Sign in to follow this  

drawing trapezoid/parallelogram with rounded corners

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
Share on other sites
Guest Anonymous Poster
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 this post


Link to post
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement