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

Sign In

Register
*Usernames are case-sensitive
Forgot my password

Circles and For Loops

  • #1 ✎ 570 random_god Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Zelda Is Awesome! I love The Legend Of Zelda! Express Yourself 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 ✎ 1665 12Me21 Head Admin Third Year My account is over 3 years old Website 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 ✎ 252 ProKuku Avatar Taboo I didn't change my avatar for 180 days Website Final(?) Contest Runner Up I placed 2nd in the (possibly) final SmileBASIC Source Contest! October 2018 Programming Contest Cthulhu Join the cult Easter Eggs https://smilebasicsource.com/page?pid=1051 I used Simeon’s code and it works fine. Posted
  • #4 ✎ 1665 12Me21 Head Admin Third Year My account is over 3 years old Website 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 ✎ 570 random_god Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Zelda Is Awesome! I love The Legend Of Zelda! Express Yourself Video Games I like to play video games! Hobbies
    https://smilebasicsource.com/page?pid=1303
    But what if 2 circles overlap?
    Posted
  • #6 ✎ 453 kenchic First Year My account is over 1 year old Website Beginner Programmer I'm just starting out! I'm still trying to grasp the basics. Programming Strength osu! Is Awesome! I love osu! Express Yourself
    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 kenchic
  • #7 ✎ 1665 12Me21 Head Admin Third Year My account is over 3 years old Website 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 ✎ 98 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 ✎ 1665 12Me21 Head Admin Third Year My account is over 3 years old Website 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 ✎ 453 kenchic First Year My account is over 1 year old Website Beginner Programmer I'm just starting out! I'm still trying to grasp the basics. Programming Strength osu! Is Awesome! I love osu! Express Yourself
    ...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