Dark Bit Factory & Gravity
PROGRAMMING => General coding questions => Topic started by: mike_g on January 07, 2007
-
I would like to find out how I could make a filled rotateable rectange function. My idea was that the function could have 5 parameters like: ROT_RECT(x, y, width, height, angle). which rotates around the center point. Help would be much appreciated.
-
The 4 points are
s = sin(angle)
c = cos(angle)
sw = width * s
cw = width * c
sh = height * s
ch = height * c
(x,y)
(x+cw,y+sw)
(x+cw-sh,y+sw+ch)
(x-sh,y+ch)
You can join them together with lines. To fill it you really need a triangle drawing routine.
Jim
-
Thanx. I got a function that draws filled triangles so I can just do two of them using co-ordinates got by that code.