? Even More Perfectly Filled Circles ● SmileBASIC Source

Sign In

Register
*Usernames are case-sensitive
Forgot my password

Even More Perfectly Filled Circles

DEF GDISK X,Y,RADIUS,COL IF RADIUS<1 THEN GPSET X,Y,COL:RETURN '(GCIRCLE draws nothing if the radius is 0) 'get the point on the graphics layer that is closest to the center of the circle VAR PX=MIN(MAX(X,0),512-1) VAR PY=MIN(MAX(Y,0),512-1) 'if the distance from the center of the circle to the closest onscreen point is 'larger than the radius, then the circle is completely offscreen VAR DX=PX-X VAR DY=PY-Y IF DX*DX+DY*DY > RADIUS*RADIUS THEN RETURN 'traditional filled circle code GCIRCLE X,Y,RADIUS,8 'draw circle with a special color GPAINT PX,PY,COL,8 'fill area inside GCIRCLE X,Y,RADIUS,COL 'redraw edge in the correct color, so none of the special color is left on screen END GPAINT x, y, fill_color, border_color will flood fill all pixels that aren't border_color. This will work even there other things on the GRP, as long as you don't use that special color. I chose 8 (that is, alpha: 0, red: 0, green: 0, blue: 8). There's no reason to ever use this color anywhere else (since it looks identical to color 0), and it should be safe. This is much faster than filling the circle manually using GLINE/GFILL/GTRI/etc.
Author
12Me21
Updated
Rating
5 votes
Categories
Keywords
  • filled
  • circle
  • disk
5 Comment(s) Yttria Yttria Head Admin Filled Circle Battle Royale: - https://smilebasicsource.com/page?pid=803 (Simeon, 2017) - https://smilebasicsource.com/page?pid=1050 (answer, 2018) - https://smilebasicsource.com/page?pid=1051 (Simeon, 2018) - https://smilebasicsource.com/page?pid=1303 (12Me21, 2019) - https://smilebasicsource.com/page?pid=1460 (Heredos, 2019) hakke hakke RNG Hidden Easter Eggs Third Year My account is over 3 years old Website Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength trying to figure out which one is better . . . ralsei ralsei Forum Leader Hidden Achievements Second Year My account is over 2 years old Website Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength AND... https://smilebasicsource.com/page?pid=???? (ralsei, 2020) MEGA MAN 10 PRESS START uh fuck wrong title screen SMILE BASIC SOURCE PRESS DIRECT 12Me21 12Me21 Power User Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself | Author | Speed | Quality | Reliability | Length | |---------+-------+---------+-------------+--------| | answer | ok | bad | good | 143 | | Simeon | good | good | ok | 286 | | 12Me21 | good | good | good | 222 | | Heredos | bad | ok | good | 346 |(Simeon's fails when the radius is less than 1, and uses the wrong values for the GRP width/height, but these are easy to fix) Performance (draws per second, n3DS) 100, 100 100, -1 program 1 10 100 1000 radius=1 10 100 1000 answer 25500 6480 378 16 26441 7163 537 25 simeon 14400 9400 472 63 34980 9856 876 failed? 12Me21 13432 9000 470 63 40234 10279 876 63 heredos 24900 920 12 0 25817 1001 13 0 Program used: M=MILLISEC+1000 WHILE MILLISEC<M C=!C <function> <x>, <y>, <radius>, C*#RED '(heredos's function requires GCOLOR, and simeon's takes an extra color argument) INC I WEND ?I Heredos Heredos Avatar Taboo I didn't change my avatar for 180 days Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Night Person I like the quiet night and sleep late. Express Yourself Need this for my game. Thanks