Once again I've come across a problem that I need assistance with. The goal was to draw a rotated ellipse if a given width and height. My initial code could produce the ellipse with no rotation. The code simply used a for loop and n many points. I found that this method worked but the ellipses formed were not always symmetrical. This probably arises from the fact that a single center point was used regardless if the shape was odd or even in width and height. This is for a lower resolution game so odd shaped ellipses aren't passable and anti aliasing would ruin the feeling of the art. I really need symmetry in these n-gon circles.
The second problem is how to go about rotating the shapes at a given angle. I tinkered around a bit with my code but could never actually implement rotation.
The two problems at a glance:
1. Symmetry is important here with no anti aliasing
2. Rotation of the ellipse is unclear to me.
The code:
A picture showing both unsymmetrical ellipses and the intended result with rotation parameter. If you look at the quadrants of the ellipse you can see that 1 and 2 are more round that qudrants 3 and 4.
The second problem is how to go about rotating the shapes at a given angle. I tinkered around a bit with my code but could never actually implement rotation.
The two problems at a glance:
1. Symmetry is important here with no anti aliasing
2. Rotation of the ellipse is unclear to me.
The code:
Function draw_oval(centerx#,centery#,width#,height#,rot#,n#) ' draw the shape with a for loop Local angle#=360.0/n Local r1#=width/2.0 Local r2#=height/2.0 For Local i=0 To n-1 Local x1=centerx+Cos(i*angle)*r1 Local x2=centerx+Cos((i+1)*angle)*r1 Local y1=centery+Sin(i*angle)*r2 Local y2=centery+Sin((i+1)*angle)*r2 DrawLine(x1,y1,x2,y2) Next End Function
A picture showing both unsymmetrical ellipses and the intended result with rotation parameter. If you look at the quadrants of the ellipse you can see that 1 and 2 are more round that qudrants 3 and 4.