Code: Select all
'some useful defines
Const Pi = 4 * Atn(1)
Dim Shared As Double TwoPi = 8 * Atn(1)
Dim Shared As Double RtoD = 180 / Pi ' radians * RtoD = degrees
Dim Shared As Double DtoR = Pi / 180 ' degrees * DtoR = radians
screenres 640,480,32
dim shared as single ww 'angle of rotation in degrees
sub drawOval(cx as integer, cy as integer, ww as double, r1 as double, r2 as double, cc as ulong, angle1 as double, angle2 as double)
dim as double dx,dy
dim as integer x1,y1,x2,y2
dim as double steps
'compute minimum pixels for circle for maximum radius
if r1>r2 then
steps = 360/(r1*TwoPi)
else
steps = 360/(r2*TwoPi)
end if
'circle center
circle (cx,cy),5,rgb(0,0,255)
for angle as double = angle1*DtoR to angle2*DtoR step steps*DtoR
dx = Cos(angle)
dy = Sin(angle)
x1 = dx*r1
y1 = dy*r2
' rotate around cx,cy
x2 = Cos(ww*DtoR) * x1 - Sin(ww*DtoR) * y1
y2 = Cos(ww*DtoR) * y1 + Sin(ww*DtoR) * x1
pset (x2+cx,y2+cy),cc
next angle
end sub
do
if inkey=" " then
ww = ww + 1
if ww>259 then ww = 360-ww
end if
screenlock
cls
locate 2,2
print "PRESS SPACE BAR TO ROTATE EGG"
drawOval(320,240,ww,100,100,rgb(255,0,0),0,180)
drawOval(320,240,ww,100,200,rgb(0,255,0),180,360)
screenunlock
sleep 2
loop until multikey(&H01)