LoginLogin
Might make SBS readonly: thread

Drawing Filled Circles

Root / Submissions / [.]

answerCreated:
A function that draws a filled circle with a selectable color. Source code: DEF FCIRCLE X,Y,R,L:_=-6.28319R=MAX(R,1)F=_/R:FOR I=_ TO.STEP-F:C=COS(I)S=SIN(I)N=COS(I-F)M=SIN(I-F)GTRI X,Y,X-C*R,Y-S*R,X-N*R,Y-M*R,L:NEXT.END Usage: FCIRCLE X, Y, R, L int X (X coordinate of origin point of circle) int Y (Y coordinate of origin point of circle) int R (Radius) int L (Color code) Example: Draws a circle in the middle of the screen with a radius of 20 pixels
FCIRCLE 200, 120, 20, -1

I couldn't help but notice your use of periods in the code. I had no idea that was legal syntax. I can understand a single period being interpreted as a 0 in the for loop, but . . . "NEXT.END"?

Replying to:MZ952
I couldn't help but notice your use of periods in the code. I had no idea that was legal syntax. I can understand a single period being interpreted as a 0 in the for loop, but . . . "NEXT.END"?
Also "TO.STEP". How?

Wait what? How does this work?? It does work (it draws the circle like a pie chart) What does TO.STEP mean? Because it doesn't work without that

Please fix the formatting on this page.

Replying to:Simeon
Wait what? How does this work?? It does work (it draws the circle like a pie chart) What does TO.STEP mean? Because it doesn't work without that
A single period is recognized as a "0" in smilebasic. Example, ?A[.] Now for the NEXT.END, I thought that maybe SB recognizes the "." token like it does spaces, and it seemed that way up until you tried it with any other command. As it turns out, the NEXT instruction accepts an optional input after it, which it promptly ignores. Simply put, NEXT X has no weight over NEXT SQR(-1), and likewise with this strange "." functionality, which it recognizes simply as "0" NEXT.END is the same code as NEXT 0 END.

Replying to:MZ952
I couldn't help but notice your use of periods in the code. I had no idea that was legal syntax. I can understand a single period being interpreted as a 0 in the for loop, but . . . "NEXT.END"?
Never mind, I figured it out lol.

Replying to:Simeon
Wait what? How does this work?? It does work (it draws the circle like a pie chart) What does TO.STEP mean? Because it doesn't work without that
So something similar applies to "TO.STEP" too?

Replying to:Simeon
Wait what? How does this work?? It does work (it draws the circle like a pie chart) What does TO.STEP mean? Because it doesn't work without that
Yes. TO.STEP is the same as TO 0 STEP.

Replying to:Simeon
Wait what? How does this work?? It does work (it draws the circle like a pie chart) What does TO.STEP mean? Because it doesn't work without that
Which I'd like to note is a useful golfing trick... when used that way. Since the rest of this code ISN'T condensed, it's just meaningless cuteness/obfuscation.

The circles that this draws are pretty ugly and deformed.

Replying to:12Me21
The circles that this draws are pretty ugly and deformed.
It seems to work OK for me (even in its one-line format). Although it isn't perfect.

I didn't even realize the terrible formatting And this is basically designed to just draw circles very quickly, not meant to be accurate

Replying to:snail_
Please fix the formatting on this page.
Sorry, I didn't realize the terrible formatting, I was on a 3DS and I didn't think it wouldn't automatically have line breaks when using the (code) blocks