Fast filled circle - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3) +---- Forum: Utilities (https://qb64phoenix.com/forum/forumdisplay.php?fid=8) +---- Thread: Fast filled circle (/showthread.php?tid=1190) |
Fast filled circle - mdijkens - 11-26-2022 I ran into issues with Paint and transparency; they don't get along very well. So I created my own filled circle routine: Code: (Select All) Sub fCircle (x%, y%, r%, c~&) It runs a lot faster then Circle & Paint and also works well with transparent colors! RE: Fast filled circle - CharlieJV - 11-26-2022 (11-26-2022, 03:20 PM)mdijkens Wrote: I ran into issues with Paint and transparency; they don't get along very well. That is very cool and very fast. Side-question/observation: Playing around with CIRCLE in GW-BASIC, the CIRCLE statement produces pretty perfect circles in every screen mode. Drawing a square box (with LINE statement using the B parameter) in GW-BASIC will result in rectangles in different screen modes. So the CIRCLE command in GW-BASIC must be doing something special to overcome the different pixel width to height ratios to always result in a circle instead of an oval. For the code above, I would expect that same code to produce ovals in GW-BASIC when in screen modes that don't have 1 to 1 for pixel width to pixel height ratios. Testing that out in QB64, the code above produces a perfect circle in every screen mode. Just to understand the evolution of screen modes from GW-BASIC to QBASIC to QB64(pe), at which point did the varying pixel width to height ratios (as existing in GW-BASIC) go away? RE: Fast filled circle - bplus - 11-26-2022 This has been tested and tested again, it uses 8 point octal calculations and holds up aginst memory techniques with even alpha shading (no overlapping), very fast and efficient. Code: (Select All) 'from Steve "Gold standard" Got it from Steve but he didn't invent it. fcirc is short for Filled Circle. The only place it doesn't work well is dbox's QBJS RE: Fast filled circle - dbox - 11-26-2022 (11-26-2022, 04:19 PM)bplus Wrote: This has been tested and tested again, it uses 8 point octal calculations and holds up aginst memory techniques with even alpha shading (no overlapping), very fast and efficient. Works fine if you comment out the unnecessary BF parameters: View in QBJS RE: Fast filled circle - bplus - 11-26-2022 (11-26-2022, 10:43 PM)dbox Wrote:(11-26-2022, 04:19 PM)bplus Wrote: This has been tested and tested again, it uses 8 point octal calculations and holds up aginst memory techniques with even alpha shading (no overlapping), very fast and efficient. Is that all it was? I couldn't remember, just that I had to do something for code to use in QBJS. The BF's was because they were somehow optimized some time ago according to Steve and it was true back in version 1.2 or so... Still true? I don't know... AS I recall, lines were better/faster than PSet's as well. RE: Fast filled circle - mdijkens - 11-26-2022 Thanks bplus for the excellent example. It got me thinking about BF option; why is it there? It seems unneeded. After experimenting, I found that the BF option, even with single line makes drawing the line 5x faster! Against common sense I added the BF option to the line statements in my code and surprise... it was 5x faster also. Now it has the same speed (even a tiny bit faster) as your routine: Code: (Select All) Sub fCircle (x%, y%, r%, c~&) RE: Fast filled circle - bplus - 11-26-2022 (11-26-2022, 11:13 PM)mdijkens Wrote: Thanks bplus for the excellent example. Ah very interesting! Thanks I like less LOC whenever it makes sense. RE: Fast filled circle - SMcNeill - 11-27-2022 (11-26-2022, 11:13 PM)mdijkens Wrote: Thanks bplus for the excellent example. As I've explained to bplus and a few others before, it makes perfect sense once you take a second to think about it... How do you calculate a vertical line?? A horizontalntal line? Or a box? for y = start to finish memfill (xpos,y) to (xpos2, y), color next ...... Now, how do you calculate and plot a sloped line? for y = start to finish step yslope for x = start to finish step xslope plot x, y, color next next ..... The first, you just fill a whole chunk of memory with one set of values in a single pass... For the second, you do a lot of math to calculate your slope and plot each point as you move upon that slope. Now, which is going to be faster than the other? RE: Fast filled circle - SMcNeill - 11-27-2022 And, if all you need is something faster than PAINT, keep in mind this simple little circlefill: SUB CircleFill (x, y, size) FOR i = 1 to size CIRCLE (x, y), size NEXT END SUB It doesn't get any simpler than that, and it's still quite a bit faster than PAINT! RE: Fast filled circle - gaslouk - 11-27-2022 Hi A good idea for the keyword of the day 020 Gaslouk |