? Circles and For Loops (Page 1) ● SmileBASIC Source Forums

Sign In

Register
*Usernames are case-sensitive
Forgot my password

Circles and For Loops

  • #1 ✎ 937 random_god Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength QSP Contest 1 Contest Participant I participated in the first SmileBASIC Source QSP Contest! Video Games I like to play video games! Hobbies Hey, how can I make a circle using a for loop? That seems the best way I can get a completely filled circle, but I can't quite get the shape. Here is my code: DEF GCIRCFL CENTX,CENTY,RADI FOR X=CENTX-RADI TO CENTX+RADI FOR Y=CENTY-RADI TO CENTY+RADI GLINE CENTX,CENTY,X,Y NEXT NEXT END GCIRCFL 200,120,20'I want this to make a circle I know this makes a box, and how that works, but no matter how I change it I can't make it a circle. Can anyone help? Posted
  • #2 ✎ 1823 12Me21 Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself https://smilebasicsource.com/page?pid=1303 Posted Edited by 12Me21
  • #3 ✎ 308 ProKuku QSP Contest 1 Contest Participant I participated in the first SmileBASIC Source QSP Contest! Night Person I like the quiet night and sleep late. Express Yourself Pokemon Is Awesome! I love Pokemon! Express Yourself https://smilebasicsource.com/page?pid=1051 I used Simeon’s code and it works fine. Posted
  • #4 ✎ 1823 12Me21 Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself
    https://smilebasicsource.com/page?pid=1051 I used Simeon’s code and it works fine.
    It doesn't work when the circle is completely in an offscreen part of the GRP.
    Posted
  • #5 ✎ 937 random_god Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength QSP Contest 1 Contest Participant I participated in the first SmileBASIC Source QSP Contest! Video Games I like to play video games! Hobbies
    https://smilebasicsource.com/page?pid=1303
    But what if 2 circles overlap?
    Posted
  • #6 ✎ 477 chicken
    https://smilebasicsource.com/page?pid=1303
    But what if 2 circles overlap?
    it uses a special color for the bounding circle which isn't used anywhere else (int form: 8) then it fills that circle with the fill color using GPAINT, specifying the special color as the boundary color so it will completely ignore other colors until it hits the bounding circle then it redraws the bounding circle with the actual (usually fill) color so there isn't any special color (8) left to mess with future filled circle drawing
    Posted Edited by chicken
  • #7 ✎ 1823 12Me21 Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself Yeah. And color 8 is RGB(0,0,0,8) All colors that are transparent (RGB(0,anything,anything,anything)) look identical, so there's no reason that anyone would use 8 rather than 0. It's safe to assume that these colors won't be used for anything else. Posted Edited by 12Me21
  • #8 ✎ 184 seggiepants If you aren't looking for real time speed or perfect accuracy, I would approximate it with triangles layed out pie chart style (triangle fan). You could even change the triangle count based on radius, although less than 3 or more than 360 is probably silly. This way you don't have to worry about flood fill running into the stop color prematurely or if it goes offscreen. (I assume the flood fill would be faster just due to less function calls) You could also try just putting in a Sprite of a filled circle and shrinking/ growing it as needed. Posted
  • #9 ✎ 1823 12Me21 Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself What you could do is draw the filled circle using GCIRCLE/GPAINT on an unused empty graphics page, then GCOPY it to the main page, if you NEED to use weird transparent pixels for some reason. Posted
  • #10 ✎ 477 chicken
    ...GCOPY it to the main page, if you NEED to use weird transparent pixels for some reason.
    at that point you'd probably just want to use a scaled circle sprite
    Posted