Drawing Ellipses on SmileBASIC
DEF ELLIPSE X,Y,SX,SY
VAR R,I,R2
FOR I=0TO 360:R2=R
R=RAD(I)
GLINE X+SX*COS(R),Y+SY*SIN(R),X+SX*COS(R2),Y+SY*SIN(R2)
NEXT
END
This basically has the same function that ellipse() does in processingJS, just ported to SmileBASIC. Submitted
 Updated
 Categories
 Keywords

FOR
example: I wrote this code to test the milliseconds it took to execute the followingM=MILLISEC FOR I=0 TO 1000000 'Just let it loop NEXT PRINT MILLISECM 'Returned approximately 750. I=0'reset the counter to 0 M=MILLISEC WHILE I<1000001 INC I WEND PRINT MILLISECM 'Returned about 675
DEF ELLIPSE X,Y,SX,SY VAR R# VAR C#=SX,S#=0 FOR R#=0 TO 6.2831853 STEP 0.01 'or something VAR OC#=C# VAR OS#=S# C#=SX*COS(R#) S#=SY*SIN(R#) GLINE X+OC#,Y+OS#,X+C#,Y+S# NEXT END
or somethingDEF ELLIPSE X,Y,SX,SY VAR R# VAR C#=SX,S#=0 FOR R#=0 TO PI()/2+PI()*2/360 STEP PI()*2/360 VAR OC#=C# C#=SX*COS(R#) S#=SY*SIN(R#) GLINE X+OC#,Y+OS#,X+C#,Y+S# GLINE XOC#,YOS#,XC#,YS# GLINE XOC#,Y+OS#,XC#,Y+S# GLINE X+OC#,YOS#,X+C#,YS# NEXT END
yours: 299 per sec. mine: 392 per sec. new: 741 per sec.GLINE X+SX*COS(R),Y+SY*SIN(R),X+SX*COS(R2),Y+SY*SIN(R2)
With this line:GTRI X+SX*COS(R),Y+SY*SIN(R),X,Y,X+SX*COS(R2),Y+SY*SIN(R2)
then it will draw a filled ellipse. c: