' kaleid14- a polar (r, theta) coordinates kaleidoscope. ' Thanks to Alyce for the help on up/down spinners. ' Thanks to CarlG for the language to express my ideas with! nomainwin WindowWidth = 560 WindowHeight = 580 UpperLeftX = 200 UpperLeftY = 10 xoffset = 260 yoffset = 250 count = 1 'Number of loops to make of each pattern sym = 3 'Basic symmetry you want ( choose 3 for six-fold kaleidoscope) PI = 3.14159265 'Faster as a constant 'constants UDS.SETBUDDYINT = hexdec( "2") UDS.ARROWKEYS = hexdec( "20") UDS.ALIGNRIGHT = hexdec( "4") calldll #comctl32, "InitCommonControls", re as void graphicbox #1.g, 20, 40, 520, 500 button #1.get, "Wash and Go!", [gorun], UL, 120, 10, 130, 24 button #1.end, "Quit", [done], UL, 500, 10, 40, 24 button #1.scr, "Save screen", [screen], UL, 400, 10, 80, 24 button #1.xr, "XOR", [xor], UL, 280, 10, 40, 24 button #1.ovr, "Over", [over], UL, 330, 10, 40, 24 textbox #1.t, 50, 10, 40, 26 open "Polar plotting kaleidoscope- V14 Oct 2002 John Fisher" for dialog as #1 #1, "trapclose [done]" #1.t "!font courier_new 12" hwndParent = hwnd( #1) hText = hwnd( #1.t) CallDLL #user32, "GetWindowLongA", hwndParent As long, _GWL_HINSTANCE As long, hInstance As long dwStyle= _WS_CHILD or _WS_VISIBLE or _WS_BORDER or UDS.SETBUDDYINT or UDS.ALIGNRIGHT or UDS.ARROWKEYS x=0: y=0: wide=0: high=0: upr=15: lwr=1: pos=3: id =1 calldll #comctl32, "CreateUpDownControl",_ dwStyle as ulong,_ 'style x as long,_ 'x placement y as long,_ 'y placement wide as long,_ 'width high as long,_ 'height hwndParent as long,_ 'parent handle id as long,_ 'an ID number hInstance as long,_ 'parent instance handle hText as long,_ 'buddy control - a textbox handle upr as long,_ 'upper limit lwr as long,_ 'lower limit pos as long,_ 'initial value hSpinner as long 'handle of control [gorun] print #1.g, "fill "; str$( 255*rnd(1)); " "; str$( 255*rnd(1)); " "; str$( 255*rnd(1)); " " count =0 while count < 100 *15 /sym 'plot rore points for the lesser symmetries r =230 *rnd( 1) 'radial distance to plotting centre is 0 <---> 100 theta =PI /sym *rnd( 1) 'angular distance to plotting centre is 0 <---> 180/sym degrees c =2 +r/10 *rnd( 1) 'radius of circles to plot around plotting centre & its symmetrical twins gosub [plot_data] count =count +1 scan #1.t "!contents? txt$" sym =val( txt$) wend print #1.g, "flush ; discard" wait [done] calldll #user32, "DestroyWindow", hSpinner as long, re as long close #1 end [plot_data] 'For each (r, theta) location, plot also (r, 0 +-theta) ( reflected across x axis) ' (r, 1 *360 /sides +-theta) ( reflected across symmetry axis) ' (r, 2 *360 /sides +-theta) ' etc.... ' BUT remember we are working in radians in LB, where 360 degrees = 2 PI radians red =255 *rnd( 1) green =255 *rnd( 1) blue =255 *rnd( 1) #1.g, "color "; red; " "; blue; " "; green #1.g, "backcolor "; red; " "; blue; " "; green for loo =0 to ( sym-1) angle =2 *PI /sym anglePlus =loo *angle +theta angleMinus =loo *angle -theta x = int( xoffset +r *sin( anglePlus)): y = int( yoffset -r *cos( anglePlus)) #1.g, "goto "; x ; " "; y ; " ; down ; circlefilled "; c; " ; up" x = int( xoffset +r *sin( angleMinus)): y = int( yoffset -r *cos( angleMinus)) #1.g, "goto "; x ; " "; y ; " ; down ; circlefilled "; c; " ; up" next loo return [screen] print #1.g, "getbmp drawing 1 1 520 520" bmpsave "drawing", "kaleido" +str$( int( 99 *rnd(1))) +".bmp" wait [xor] #1.g, "rule xor" wait [over] #1.g, "rule over" wait end