OPTION STRICT
OPTION DEFINT
DEF ELLIPSE ORGX,ORGY,RDSX,RDSY,COL
DIM X,Y,PX,PY=-RDSY
DIM TST#,PTST#
DIM RDSX_SQRD=RDSX*RDSX
DIM RDSY_SQRD=RDSY*RDSY
DIM STEP=2
FOR Y=-RDSY TO STEP STEP STEP
FOR X=-RDSX TO STEP STEP STEP
PTST#=TST#
TST#=X*X/RDSX_SQRD+Y*Y/RDSY_SQRD
IF PTST#>1 && TST#<=1 THEN
GLINE X+ORGX,Y+ORGY,PX+ORGX,PY+ORGY,COL
GLINE -X+ORGX,Y+ORGY,-PX+ORGX,PY+ORGY,COL
GLINE X+ORGX,-Y+ORGY,PX+ORGX,-PY+ORGY,COL
GLINE -X+ORGX,-Y+ORGY,-PX+ORGX,-PY+ORGY,COL
PX=X:PY=Y
X=-RDSX/(Y+RDSY+3)
Y=Y+STEP
ENDIF
NEXT X
NEXT Y
ENDELLIPSE OriginX, OriginY, RadiusX, RadiusY, Color Code
Got an idea for (probably) fast filled ellipse drawing too.
Increment STEP to draw faster. Every increment just about cuts the drawing time down by three. STEP=2 is best imo.Fast ellipse drawing
Root / Submissions / [.]
I'm actually very surprised how difficult it was to create an ellipse function that draws faster than the typical approach with the loop over radians and calling SIN and COS. I thought those functions were slow, but they're actually not. I guess they probably do nothing more than call values from an internal table.
