Sierpinski Circled bplus Junior Member Posts: 32 Threads: 8 Joined: Jul 2018 Reputation: 0 07-21-2018, 11:50 PM (This post was last modified: 07-21-2018, 11:56 PM by bplus.) Sierpinski triangle done with only circles, generalized to any regular polygon and then made to move with alpha detailing: Code:```'Sierpinski circled.txt ' written for Naalaa 6 by bplus 2018-07-21 ' translated from Sierepinski Circled.bas by bplus 2018-04-04 QB64 v 11-06-2017 ' A new twist on an old fractal. '  Sierpinski triangle generalized and made dynamic for any regular poly though does not work well beyond 8 or 9. randomize time() + rnd(100) radians constant: wW 700 wH 700 visible: pi# = acos#(-1.0) pi2# = 2.0 * pi# pip5# = pi# * 0.5 pi360# = pi# / 360.0 cx# = float(wW / 2) cy# = float(wH / 2) cr# = float(wH) / 6.0 r# g# b# levels hidden: set window 100, 20, wW, wH set redraw false for n = 3 to 8 'n = 3     a# = 0.0     r# = float(56 + rnd(200)); g# = float(56 + rnd(200)); b# = float#(56 + rnd(200))     levels = 12 - n     shade = 255     while a# <= pi2#         set color 0, 0, 0         draw rect 0, 0, wW, wH, true         _recurringCircles cx#, cy#, cr#, a#, n, levels         a# = a# + pi360#         redraw         wait 1  wend     _pause next procedure recurringCircles (x#, y#, rr#, ao#, n, level)     cf# = float(12 - level) / 12.0     'try this with alpha maybe 50 but kind of dark and blurry     'without alpha, too much overlap to show fine pattern detail     set color int(r#*cf#), int(g#*cf#), int(b#*cf#), 50     draw ellipse int(x), int(y), int(rr#), int(rr#), true     if level > 0         pi5# = pi# * 0.5         ra# = pi2# / float(n)         for i = 0 to n - 1             x1# = x# + 1.5 * rr# * cos#(float(i) * ra# + ao# - pip5#)             y1# = y# + 1.5 * rr# * sin#(float(i) * ra# + ao# - pip5#)             _recurringCircles x1#, y1#, rr# * 0.5, 2.0 * ao#, n, level - 1         next     endif endproc procedure pause()     set color 200, 225, 250     wln "Click mouse to continue..."     redraw     wait mousebutton endproc``` OK, copy / paste from forum ran fine for me after deleting blank first line. b = b + geberation pedromartins Junior Member Posts: 36 Threads: 18 Joined: Jun 2018 Reputation: 0   07-22-2018, 12:16 AM Hi bplus Nice job bplus Junior Member Posts: 32 Threads: 8 Joined: Jul 2018 Reputation: 0 07-22-2018, 01:01 AM Hi pedromartins, Thanks! I see you are quite the bug collector! I don't know if you have noticed the power problem yet or not but I have an idea for it. Stay tuned... b = b + geberation bplus Junior Member Posts: 32 Threads: 8 Joined: Jul 2018 Reputation: 0 07-22-2018, 03:34 PM (This post was last modified: 07-22-2018, 04:16 PM by bplus.) Hi Rick,  I tried opaque coloring, different levels with different colors, but  the overlap completely ruins the quality of the fine patterns created by overlapping transparent coloring. This is definitely an applicaion that calls for alpha coloring. I tried all afternoon to match the alpha quality of Naalaa images to those from original code language. A wasted afternoon. Heck, the quality doesn't even match the screen shots I posted at Retrogamecoding. Oh well, Naalaa never claimed to be graphics language. Still, it is cool to get so much bang! out of so few bytes. I mean doing Sierpinski polygons with just circles in a dozen lines... wow! Here it is coded for max brightness: Code:```'Sierpinski circled max brightness.txt ' written for Naalaa 6 by bplus 2018-07-22 ' translated from Sierepinski Circled.bas by bplus 2018-04-04 QB64 v 11-06-2017 ' A new twist on an old fractal. '  Sierpinski triangle generalized and made dynamic for any regular poly though does not work well beyond 8 or 9. '2018-07-22 max brightness, slowed down in attempt to elimianate blurriness radians constant: wW 700 wH 700 visible: pi# = acos#(-1.0) pi2# = 2.0 * pi# pip5# = pi# * 0.5 pi360# = pi# / 360.0 cx# = float(wW / 2) cy# = float(wH / 2) cr# = float(wH) / 6.0 shade hidden: set window 100, 20, wW, wH set redraw false for n = 3 to 8     a# = 0.0     levels = 12 - n     'calculate max shade apha available     shade = 255 / levels     while a# <= pi2# / float(n)         set color 0, 0, 0         draw rect 0, 0, wW, wH, true         _recurringCircles cx#, cy#, cr#, a#, n, levels         a# = a# + pi360#         redraw         wait 60   wend     _pause next procedure recurringCircles (x#, y#, rr#, ao#, n, level)     set color 255, 255, 255, shade     draw ellipse int(x), int(y), int(rr#), int(rr#), true     if level > 0         pi5# = pi# * 0.5         ra# = pi2# / float(n)         for i = 0 to n - 1             x1# = x# + 1.5 * rr# * cos#(float(i) * ra# + ao# - pip5#)             y1# = y# + 1.5 * rr# * sin#(float(i) * ra# + ao# - pip5#)             _recurringCircles x1#, y1#, rr# * 0.5, 2.0 * ao#, n, level - 1         next     endif endproc procedure pause()     set color 200, 225, 250     wln "Click mouse to continue..."     redraw     wait mousebutton endproc``` There should be 9 shades of brightness in triangle where 9 overlapping circles occur, yet there seems only 2 shades one the color of circle if no overlap, the other, a shade where any amount of overlap occurs. Maybe because of recursive drawing one level should be completely draw and then the next layered over it. Wait.. No there still should be another shade when a big circle (higher level) is drawn over a smaller (lower level one). b = b + geberation bplus Junior Member Posts: 32 Threads: 8 Joined: Jul 2018 Reputation: 0 07-22-2018, 05:37 PM Well this test works fine: Code:```'overlapping alpha rectangles set window 100, 40, 600, 600 set color 255, 255, 255, 25 for i = 1 to 10     draw rect 50 + i * 20, 50 + i * 20, 500 - i * 40, 500 - i * 40, true next wait keydown``` b = b + geberation bplus Junior Member Posts: 32 Threads: 8 Joined: Jul 2018 Reputation: 0 07-22-2018, 06:39 PM (This post was last modified: 07-24-2018, 01:38 PM by bplus.) AHA! This is 100% more satisfactory! I had to overlap the 3 outer circles to the inner one in the recursive calls, instead of having them tangent to the inner circle. What a difference that made! Code:```'Sierpinski circled best yet.txt  ' written for Naalaa 6 by bplus started 2018-07-22 ' translated from Sierepinski Circled.bas by bplus 2018-04-04 QB64 v 11-06-2017 ' A new twist on an old fractal. '  Sierpinski triangle made from circles only, generalized and made dynamic  '  for any regular poly though does not work well beyond 8 or 9. '2018-07-22 max brightness, slowed down in attempt to elimianate blurriness '2018-07-22 best yet: have the new set of 3 circles overlap the interior, instead of tangent to interior circle '2018-07-23 calculating a couple of variables too often in recursive sub, only need ra# once with each new n  ' and pip5# was already done! radians constant: wW 720 wH 720 shade 50 visible: pi# = acos#(-1.0) pi2# = 2.0 * pi# pip5# = pi# * 0.5 pi360# = pi# / 360.0 cx# = float(wW / 2) cy# = float(wH / 2) cr# = float(wH) / 4.0 ra# hidden: set window 100, 10, wW, wH set redraw false for n = 3 to 8     a# = 0.0     ra# = pi2# / float(n)     levels = 12 - n     while a# < ra#         set color 0, 0, 0         draw rect 0, 0, wW, wH, true         _recurringCircles cx#, cy#, cr#, a#, n, levels         a# = a# + pi360#         redraw         wait 10    wend     set color 0, 0, 0     draw rect 0, 0, wW, wH, true     _recurringCircles cx#, cy#, cr#, 0.0, n, levels     _pause next procedure recurringCircles (x#, y#, rr#, ao#, n, level)     set color 100, 255, 100, shade     draw ellipse int(x), int(y), int(rr#), int(rr#), true     if level > 0         for i = 0 to n - 1             x1# = x# + rr# * cos#(float(i) * ra# + ao# - pip5#)             y1# = y# + rr# * sin#(float(i) * ra# + ao# - pip5#)             _recurringCircles x1#, y1#, rr# * 0.5, 2.0 * ao#, n, level - 1         next     endif endproc procedure pause()     set caret 10, 10     set color 200, 225, 250     wln "Click mouse to continue..."     redraw     wait mousebutton endproc```Here is link to screen shots at Retro if you are member: http://retrogamecoding.org/board/index.php?topic=650.0 EDIT: 2018-07-23 made a couple of code fixes to reduce number of calculations being made in the recursive sub, does not effect screen shot. Oh I can link to image directly: http://retrogamecoding.org/board/index.p...1600;image http://retrogamecoding.org/board/index.p...1602;image b = b + geberation « Next Oldest | Next Newest »