08-14-2022, 05:24 PM
That's cool, it's reminiscent of Steve's circle fill algorithm.
I was playing with it a bit and came up with a few optimizations and observations.
Substituting 's' for 20 makes it a snap to change the size. Adding yy = s - xx, and moving the second line command into the first iteration, eliminates the entire second reversed iteration.
Also, try running it with the SLEEP command enabled and watch the action. The quarter stepping means that the loop will run 4 times for each time anything is drawn, since the drawing only advances on whole integers. Then comment out the STEP .25, with sleep still enabled, and watch the action. My testing so far indicates the quarter stepping is unnecessary for the end result and just adds processing time.
The sleep trick was how I figured out how Steve's circle fill routine worked, so when I tried it here, it revealed the extra cycles.
It would make a great little SUB that you can send position and size parameters (or even color) to, and throw them up anywhere on the screen.
I was playing with it a bit and came up with a few optimizations and observations.
Code: (Select All)
SCREEN _NEWIMAGE(800, 600, 32)
x = 400
y = 300
s = 20
FOR xx = 0 TO s STEP .25
yy = s - xx
LINE (x + xx, y + xx)-(x - xx, y + xx)
LINE (x + yy, y - yy + _SHL(s, 1))-(x - yy, y - yy + _SHL(s, 1))
'SLEEP
NEXT xx
Substituting 's' for 20 makes it a snap to change the size. Adding yy = s - xx, and moving the second line command into the first iteration, eliminates the entire second reversed iteration.
Also, try running it with the SLEEP command enabled and watch the action. The quarter stepping means that the loop will run 4 times for each time anything is drawn, since the drawing only advances on whole integers. Then comment out the STEP .25, with sleep still enabled, and watch the action. My testing so far indicates the quarter stepping is unnecessary for the end result and just adds processing time.
The sleep trick was how I figured out how Steve's circle fill routine worked, so when I tried it here, it revealed the extra cycles.
It would make a great little SUB that you can send position and size parameters (or even color) to, and throw them up anywhere on the screen.
DO: LOOP: DO: LOOP
sha_na_na_na_na_na_na_na_na_na:
sha_na_na_na_na_na_na_na_na_na: