'=========================================================================== ' Subject: PATTERNED WALLPAPER GENERATOR Date: 12-17-98 (17:52) ' Author: David Szafranski Code: LB ' Origin: digital_paris@csi.com Packet: LIBERTY.ABC '=========================================================================== 'PsychoPattern V1.1 Patterned Wallpaper Generator 'This program draws various types of tileable patterns to be used 'for background patterns for webpages or whatever! 'All code is in public domain. Feel free to modify or use as you want. 'David Szafranski July 1998 nomainwin dim amp1$(14) dim amp2$(14) dim period1$(14) dim period2$(14) pi = 3.1415926535896 WindowWidth = 350 WindowHeight = 247 UpperLeftX = int((DisplayWidth - WindowWidth) / 2) UpperLeftY = int((DisplayHeight - WindowHeight) / 2) button #sine, "Cells!", [cells], UL, 0, 0, 342, 40 button #sine, "Waves!", [waves], UL, 0, 40, 342, 40 button #sine, "Spheres!", [spheres], UL, 0, 80, 342, 40 button #sine, "Moires!", [moires], UL, 0, 120, 342, 40 button #sine, "Change Wallpaper!", [wallpaper], UL, 0, 160, 342, 40 menu #sine, "&File", "&Quit", [quit] menu #sine, "&Choose Pattern!", "&Cells", [cells], "&Waves", [waves], "&Spheres", [spheres], "&Moires", [moires] menu #sine, "Create &Wallpaper", "Change &Wallpaper", [wallpaper] open "Psycho Pattern v1.1" for graphics_nsb as #sine print #sine, "trapclose [quit]" [mainLoop] input aVar$ goto [mainLoop] [wallpaper] FILEDIALOG "Open Wallpaper bmp", "*.bmp", filenm$ if filenm$ = "" then [mainLoop] ' Const SPIF_UPDATEINIFILE = &H1 ' Const SPI_SETDESKWALLPAPER = 20 'value for uAction ' Const SPIF_SENDWININICHANGE = &H2 ' filenm$ = "C:\Windows\Carved Stone.bmp" uAction = 20 fuWinIni = hexdec("&H1") or hexdec("&H2") ' "User" (ByVal uAction As Integer, ByVal uparam As Integer, lpvParam As Any, ByVal fuWinIni As Integer) As Integer ' open the DLL open "User.dll" for dll as #User ' Make the call calldll #User, "SystemParametersInfo", _ uAction as word, _ uparam as word, _ filenm$ as PTR, _ fuWinIni as word, _ result as word ' close the dll close #User goto [mainLoop] [quit] close #sine end '================================================================= [cells] WindowWidth = 550 WindowHeight = 470 UpperLeftX = int((DisplayWidth - WindowWidth) / 2) UpperLeftY = int((DisplayHeight - WindowHeight) / 2) combobox #main.cells.parameters.amp1, amp1$(, [cellsLoop], 390, 70, 45, 100 combobox #main.cells.parameters.amp2, amp2$(, [cellsLoop], 390, 170, 45, 100 combobox #main.cells.parameters.period1, period1$(, [cellsLoop], 390, 270, 45, 100 combobox #main.cells.parameters.period2, period2$(, [cellsLoop], 390, 370, 45, 100 graphicbox #main.cells.parameters, 378, 50, 150, 362 graphicbox #main.cells.drawing, 10, 50, 362, 362 button #main.cells.draw, "Draw!", [drawCells], UL, 10, 10, 75, 20 button #main.cells.stop, "Stop!", [endLoop], UL, 85, 10, 75, 20 button #main.cells.save, "Save!", [saveBmp], UL, 160, 10, 75, 20 button #main.cells.exit, "Exit!", [quitCells], UL, 235, 10, 75, 20 graphicbox #main.cells, 0, 0, 542, 440 open "Pseudo Sine!" for dialog_modal as #main print #main, "trapclose [quitCells]" bmpWnd=hwnd(#main.cells.drawing) 'this is needed for savebmp sub print #main.cells, "down; fill lightgray; flush" print #main.cells.parameters, "down; fill lightgray; flush" boxTitle$ = "Parameters" x = 2 y = 8 boxWidth = 144 boxHeight = 350 gosub [draw3DBox] print #main.cells.parameters, "place 60, 35" print #main.cells.parameters, "\Amplitude 1" print #main.cells.parameters, "place 60, 135" print #main.cells.parameters, "\Amplitude 2" print #main.cells.parameters, "place 60, 235" print #main.cells.parameters, "\Period 1" print #main.cells.parameters, "place 60, 335" print #main.cells.parameters, "\Period 2" '3D lines print #main.cells, "color darkgray; line 376 48 527 48; line 376 48 376 412" print #main.cells, "color white; line 376 411 529 411; line 527 411 527 48" print #main.cells, "color darkgray; line 8 48 371 48; line 8 48 8 412" print #main.cells, "color white; line 8 411 373 411; line 371 411 371 48" print #main.cells, "color darkgray; line 0 0 545 0; line 0 0 0 442" 'initialize all variables with default values amp1DefIndex = 3 'set up default index values for variables amp2DefIndex = 5 period1DefIndex = 3 period2DefIndex = 6 data$ = "2,4,8,9,10,12,15,20,24,36,40,45,90,180" count = 0 while data$ <> "" length = len(data$) x = instr(data$, ",") if x = 0 then amp1$(count) = trim$(data$): amp2$(count) = amp1$(count): _ period1$(count) = amp1$(count): period2$(count) = amp1$(count) : _ data$ = "" : goto [finish] amp1$(count) = left$(data$, x-1) amp2$(count) = amp1$(count): period1$(count) = amp1$(count): period2$(count) = amp1$(count) data$ = right$(data$,length-x) count = count + 1 [finish] wend print #main.cells.parameters.amp1, "reload" print #main.cells.parameters.amp2, "reload" print #main.cells.parameters.period1, "reload" print #main.cells.parameters.period2, "reload" print #main.cells.parameters.amp1, "selectindex "; amp1DefIndex print #main.cells.parameters.amp2, "selectindex "; amp2DefIndex print #main.cells.parameters.period1, "selectindex "; period1DefIndex print #main.cells.parameters.period2, "selectindex "; period2DefIndex [cellsLoop] input aVar$ goto [cellsLoop] [drawCells] 'get parameters from comboboxes print #main.cells.parameters.amp1, "selection?" : input #main.cells.parameters.amp1, amp1$ amp1 = val(amp1$) print #main.cells.parameters.amp2, "selection?" : input #main.cells.parameters.amp2, amp2$ amp2 = val(amp2$) print #main.cells.parameters.period1, "selection?" : input #main.cells.parameters.period1, period1$ period1 = val(period1$) print #main.cells.parameters.period2, "selection?" : input #main.cells.parameters.period2, period2$ period2 = val(period2$) open "user" for dll as #user open "gdi" for dll as #gdi ' cursor hourglass print #main.cells.drawing, "cls" print #main.cells.drawing, "down; fill lightgray; flush" h=hwnd(#main.cells.drawing) calldll#user,"GetDC",_ h as word,_ hdc as word ' amp1 = 4 'multiples of 360: ' amp2 = 20 ' period1 = 9 'multiples of 360: 2,4,8,9,10,12,15,20,24,36,40,45,90,180 ' period2 = 9 gbox = 360 bmpWide=gbox/2 bmpHigh=gbox/2 rtd = pi/180 for x = 0 to bmpWide-1 for y = 0 to bmpHigh-1 color=abs( int( (amp1*sin(period1*rtd*(x+y))+amp2*cos(period2*rtd*(x-y)))*255/(amp1+amp2) ) ) c = color + color * 256 + color * 65536 xset = x yset = y calldll#gdi,"SetPixel",_ hdc as word,_ xset as short,_ yset as short,_ c as long,_ result as long scan next y goto [nextX] [endLoop] x = 359 [nextX] next x gosub [tile.it] ' cursor normal calldll#user,"ReleaseDC",h as word,hdc as word,result as ushort close #user close #gdi goto [cellsLoop] [saveBmp] gosub [saveBmpNow] goto [cellsLoop] [quitCells] close #main goto [mainLoop] '================================================ [waves] WindowWidth = 446 WindowHeight = 400 UpperLeftX = int((DisplayWidth - WindowWidth) / 2) UpperLeftY = int((DisplayHeight - WindowHeight) / 2) button #waves.draw, "Draw!", [drawWaves], UL, 10, 10, 75, 20 button #waves.save, "Save!", [saveAsBmp], UL, 85, 10, 75, 20 button #waves.exit, "Exit!", [quitWaves], UL, 160, 10, 75, 20 checkbox #waves.squeeze, "", [wavesLoop], [wavesLoop], 10, 318, 14, 14 combobox #waves.amp, amp$(, [wavesLoop], 290, 70, 50, 100 combobox #waves.period, period$(, [wavesLoop], 290, 170, 50, 100 combobox #waves.repeat, repeat$(, [wavesLoop], 290, 270, 50, 100 graphicbox #waves.parameters, 278, 50, 150, 258 graphicbox #waves.drawing, 10, 50, 258, 258 graphicbox #waves.back, 0, 0, 438, 370 open "Waves!" for dialog_modal as #waves print #waves, "trapclose [quitWaves]" bmpWnd=hwnd(#waves.drawing) 'this is needed for savebmp sub print #waves, "down; fill lightgray; flush" print #waves.parameters, "down; fill lightgray; flush" print #waves.back, "down; fill lightgray; flush" boxTitle$ = "Parameters" x = 2 y = 8 boxWidth = 144 boxHeight = 244 gosub [drawWaves3DBox] print #waves.parameters, "place 65, 35" print #waves.parameters, "\Amplitude" print #waves.parameters, "place 65, 135" print #waves.parameters, "\Period" print #waves.parameters, "place 65, 235" print #waves.parameters, "\Repeat" print #waves.back, "place 29, 329" print #waves.back, "backcolor lightgray" print #waves.back, "\Add Squeeze!" print #waves.back, "flush" ' 3D lines print #waves.back, "color darkgray; line 276 48 427 48; line 276 48 276 308" print #waves.back, "color white; line 276 307 429 307; line 427 307 427 48" print #waves.back, "color darkgray; line 8 48 267 48; line 8 48 8 308" print #waves.back, "color white; line 8 307 269 307; line 267 307 267 48" 'initialize all variables with default values gbox = 256 'size of graphic box waves.drawing ampDefIndex = 4 'set up default index values for variables periodDefIndex = 3 repeatDefIndex = 4 for i = 0 to 6 'fill variables for comboboxes x$ = str$(2 ^(i+2)) length = len(x$) x$ = left$(x$,length-2) period$(i) = x$ repeat$(i) = x$ next i for i = 0 to 5 x$ = str$(2 ^(i+1)) length = len(x$) x$ = left$(x$,length-2) amp$(i) = x$ next i print #waves.amp, "reload" 'load comboboxes print #waves.period, "reload" print #waves.repeat, "reload" print #waves.squeeze, "reset" print #waves.amp, "selectindex "; ampDefIndex 'initiate comboboxes with defaults print #waves.period, "selectindex "; periodDefIndex print #waves.repeat, "selectindex "; repeatDefIndex [wavesLoop] input aVar$ goto [wavesLoop] [drawWaves] print #waves.drawing, "cls; down; fill lightgray; flush" open "user" for dll as #user open "gdi" for dll as #gdi cursor hourglass dim sinTable(768) h=hwnd(#waves.drawing) calldll#user,"GetDC",_ h as word,_ hdc as word 'get parameters from comboboxes print #waves.amp, "selection?" : input #waves.amp, amp$ amp = val(amp$) print #waves.period, "selection?" : input #waves.period, period$ period = val(period$) print #waves.repeat, "selection?" : input #waves.repeat, repeat$ repeat = val(repeat$) print #waves.squeeze, "value?" input #waves.squeeze, result$ if result$ = "set" then squeeze = 1 '0=off, 1 = on if result$ = "reset" then squeeze = 0 ' repeat = 32 'number of values of gray to use: 256,128,64,32,16,8,4 ' squeeze = 0 ' 0=off, 1=on ' amp = 16 'multiple of 256: 2,4,8,16,32,64 ' period = 16 'multiple of 256: 4,8,16,32,64,128,256 bmpWide=repeat bmpHigh=period if squeeze = 1 and period = 4 then bmpHigh = period if squeeze = 1 and period = 8 then bmpHigh = 2*period if squeeze = 1 and period = 16 then bmpHigh = 4*period if squeeze = 1 and period = 32 then bmpHigh = 8*period if squeeze = 1 and period > 32 then notice _ "Period Too High - Try a Lower Value" : goto [leave] 'do not use values for period >32 for squeeze for i = 1 to gbox + amp 'create sine array s = i/period * 2 *pi valueA = sin(s) * amp 'round number up or down to nearest integer valueB = int(valueA) valueC = valueA - valueB adjustedC = valueC + 0.5 multiples = int(adjustedC) valueA = valueB + multiples sinTable(i-1) = valueA next i index = 0 dim c(256) for x = 0 to 255 step 256/repeat c(index) = x + x*256 + x*65536 'create RGB values - gray scale index = index + 1 numColors = index next x index = 0 for y = 0 to bmpHigh-1 if squeeze = 0 then index = 0 for x = (-1 * amp) to bmpWide-1 +amp if index > numColors then index = 0 c = c(index) xset = x + sinTable(y + amp) if xset < 0 then index = index + 1 : goto [nextXX] if xset > gbox then index = index + 1 : goto [nextXX] yset = y calldll#gdi,"SetPixel",_ hdc as word,_ xset as short,_ yset as short,_ c as long,_ result as long index = index + 1 [nextXX] next x [nextY] next y gosub [tileWaves] [leave] cursor normal calldll#user,"ReleaseDC",h as word,hdc as word,result as ushort close #user close #gdi goto [wavesLoop] [saveAsBmp] gosub [saveBmpNow] goto [wavesLoop] [quitWaves] close #waves goto [mainLoop] '================================================ [spheres] checkFlag = 1 WindowWidth = 500 WindowHeight = 450 UpperLeftX = int((DisplayWidth - WindowWidth) / 2) UpperLeftY = int((DisplayHeight - WindowHeight) / 2) button #spheres.draw, "Draw!", [drawSpheres], UL, 10, 10, 74, 20 button #spheres.stop, "Stop!", [endSpheresLoop], UL, 85, 10, 74, 20 button #spheres.save, "Save!", [saveSpheresBmp], UL, 160, 10, 74, 20 button #spheres.exit, "Exit!", [quitSpheres], UL, 235, 10, 74, 20 combobox #spheres.large, large$(, [spheresLoop], 330, 70, 50, 100 combobox #spheres.small, small$(, [spheresLoop], 330, 170, 50, 100 checkbox #spheres.color, "", [spheresLoop], [spheresLoop], 10, 362, 14, 14 checkbox #spheres.size, "", [spheresLoop], [spheresLoop], 10, 392, 14, 14 graphicbox #spheres.drawing, 10, 50, 302, 302 graphicbox #spheres.back, 0, 0, 492, 420 open "Spheres!" for dialog_modal as #spheres print #spheres, "trapclose [quitSpheres]" bmpWnd=hwnd(#spheres.drawing) 'this is needed for savebmp sub print #spheres, "down; fill lightgray; flush" print #spheres.back, "down; fill lightgray; flush" print #spheres.back, "backcolor lightgray" 'draw 3D lines print #spheres.back, "color darkgray; line 8 48 311 48; line 8 48 8 350" print #spheres.back, "color white; line 8 351 313 351; line 311 351 311 48" print #spheres.back, "color darkgray; line 0 0 495 0; line 0 0 0 422" boxTitle$ = "Parameters" x = 322 y = 50 boxWidth = 154 boxHeight = 302 gosub [drawSpheres3DBox] print #spheres.back, "place 383, 85" print #spheres.back, "\Large Sphere" print #spheres.back, "place 383, 185" print #spheres.back, "\Small Sphere" print #spheres.color, "reset" 'initiate checkboxes print #spheres.size, "reset" print #spheres.back, "place 29, 373" print #spheres.back, "\Create Random Colors!" print #spheres.back, "place 29, 403" print #spheres.back, "\Create Random Size Spheres!" print #spheres.back, "flush" largeDefIndex = 6 'set up default index values for variables smallDefIndex = 4 for i = 0 to 9 'fill variables for comboboxes large$(i) = str$(5 * (i+3)) next i for i = 0 to 9 small$(i) = str$(2 *(i+3)) next i print #spheres.large, "reload" 'load comboboxes print #spheres.small, "reload" print #spheres.large, "selectindex "; largeDefIndex 'initiate comboboxes with defaults print #spheres.small, "selectindex "; smallDefIndex [spheresLoop] input aVar$ goto [spheresLoop] [drawSpheres] gbox = 300 print #spheres.drawing, "cls" print #spheres.drawing, "down; fill lightgray; flush" flag = 1 'flag for exit out of drawSpheres loop RandomN.Seed = 0 print #spheres.color, "value?" input #spheres.color, result$ if result$ = "set" then colorFlag = 1 '0=off, 1 = on if result$ = "reset" then colorFlag = 0 ' colorFlag = 0 ' radiusFlag = 1 print #spheres.size, "value?" input #spheres.size, result$ if result$ = "set" then radiusFlag = 1 '0=off, 1 = on if result$ = "reset" then radiusFlag = 0 print #spheres.large, "selection?" : input #spheres.large, large$ radius = val(large$) print #spheres.small, "selection?" : input #spheres.small, small$ redRadius = val(small$) ' redRadius = 7 ' radius = 30 if redRadius >= radius then notice "Please lower value for small sphere!" : goto [spheresLoop] print #spheres.drawing, "size 2; down" while flag = 1 if radiusFlag = 1 then gosub [RandomN]: redRadius = int(RandomN.RN * 10) + 5 if radiusFlag = 1 then gosub [RandomN]: radius = int(RandomN.RN * 50) + 20 scan gosub [setColors] gosub [RandomN] y = int(RandomN.RN * gbox) + 1 gosub [RandomN] x = int(RandomN.RN * gbox) + 1 if (x < radius or x + radius > gbox) and (y > radius or y + radius < gbox) then gosub [extraBallX] if (y < radius or y + radius > gbox) and (x > radius or x + radius < gbox) then gosub [extraBallY] if (x < radius or x + radius > gbox) and (y < radius or y + radius > gbox) then gosub [extraCornerBalls] x2 = x y2 = y gosub [drawBall] gosub [drawRedBall] goto [nextBall] [endSpheresLoop] flag = 0 [nextBall] wend print #spheres.drawing, "flush" goto [spheresLoop] [saveSpheresBmp] gosub [saveBmpNow] goto [spheresLoop] [quitSpheres] close #spheres goto [mainLoop] ' Random Number Generator from a Brosco Newsletter ' Functions ' [RandomN] Generates Random Numbers starting with the SEED value ' supplied in RandomN.Seed ' INPUT: RandomN.Seed value of 0 to 199017 to SEED the RNG. If a ' value of 0 is given, the LB Rnd function is ' called to give a Random Seed. ' OUTPUT: RandomN.RN Returns a value between 0 and 1. ' [RandomN] if RandomN.Seed = 0 then gosub [RandomN.SeedRNG] RandomN.C1=24298 RandomN.C2=99991 RandomN.C3=199017 RandomN.SeedTmp = RandomN.C1 * RandomN.Seed + RandomN.C2 RandomN.Seed = RandomN.SeedTmp - int( RandomN.SeedTmp / RandomN.C3 ) * RandomN.C3 RandomN.RN = RandomN.Seed / RandomN.C3 return [RandomN.SeedRNG] RandomN.Seed = rnd(1) * 199017 return [extraBallX] if x < radius then x2 = gbox + x if x+ radius > gbox then x2 = x - gbox y2 = y gosub [drawBall] gosub [drawRedBall] return [extraBallY] if y < radius then y2 = gbox + y if y+radius > gbox then y2 = y - gbox x2 = x gosub [drawBall] gosub [drawRedBall] return [extraCornerBalls] ' draw balls in 3 respheresing corners if x < radius and y+radius > gbox then x2 = gbox + x : y2 = y-gbox if x < radius and y < radius then x2 = gbox + x : y2 = gbox + y if x + radius > gbox and y < radius then x2 = x - gbox : y2 = gbox + y if x + radius > gbox and y+radius > gbox then x2 = x - gbox : y2 = y - gbox gosub [drawBall] gosub [drawRedBall] gosub [extraBallX] gosub [extraBallY] return [drawBall] red2 = red green2 = green blue2 = blue for r= radius to redRadius step -1 print #spheres.drawing, "color "; red2; " "; green2; " "; blue2 print #spheres.drawing, "place "; x2; " "; y2 print #spheres.drawing, "circle "; r ' print #spheres.drawing, "flush" green2 = int(green2 + (255 / (radius))) if green2 > 255 then green2 = 255 red2 = int(red2 + (255 / (radius))) if red2 > 255 then red2 = 255 blue2 = int(blue2 + (255 / (radius))) if blue2 > 255 then blue2 = 255 next r return [drawRedBall] red2 = 255 green2 = 0 blue2 = 0 for r = redRadius to 1 step -1 print #spheres.drawing, "color "; red2; " "; green2; " "; blue2 print #spheres.drawing, "place "; x2; " "; y2 print #spheres.drawing, "circle "; r ' print #spheres.drawing, "flush" green2 = int(green2 + (255 / (redRadius))) if green2 > 255 then green2 = 255 red2 = int(red2 + (255 / (redRadius))) if red2 > 255 then red2 = 255 blue2 = int(blue2 + (255 / (redRadius))) if blue2 > 255 then blue2 = 255 next r return [setColors] if colorFlag = 1 then _ gosub [RandomN] : _ red = int(RandomN.RN * 255) + 1 : _ gosub [RandomN] : _ green = int(RandomN.RN * 255) + 1 : _ gosub [RandomN] : _ blue = int(RandomN.RN * 255) + 1 if colorFlag = 0 then _ gosub [RandomN] : _ red = int(RandomN.RN * 255) + 1 : _ green = red : _ blue = red return '=============================================== [moires] WindowWidth = 455 WindowHeight = 420 UpperLeftX = int((DisplayWidth - WindowWidth) / 2) UpperLeftY = int((DisplayHeight - WindowHeight) / 2) button #moire.draw, "Draw!", [drawMoire], UL, 10, 10, 74, 20 button #moire.stop, "Stop!", [endMoireLoop], UL, 85, 10, 74, 20 button #moire.save, "Save!", [saveMoireBmp], UL, 160, 10, 74, 20 button #moire.exit, "Exit!", [quitMoire], UL, 235, 10, 74, 20 combobox #moire.a, a$(, [moireLoop], 286, 70, 50, 100 combobox #moire.factor, factor$(, [moireLoop], 286, 170, 50, 100 checkbox #moire.color, "", [moireLoop], [moireLoop], 10, 322, 14, 14 graphicbox #moire.drawing, 10, 50, 256, 256 graphicbox #moire.back, 0, 0, 447, 390 open "Moire!" for dialog_modal as #moire print #moire, "trapclose [quitMoire]" bmpWnd=hwnd(#moire.drawing) 'this is needed for savebmp sub print #moire, "down; fill lightgray; flush" print #moire.back, "down; fill lightgray; flush" print #moire.back, "backcolor lightgray" 'draw 3D lines print #moire.back, "color darkgray; line 8 48 266 48; line 8 48 8 306" print #moire.back, "color white; line 8 305 266 305; line 265 305 265 48" print #moire.back, "color darkgray; line 0 0 450 0; line 0 0 0 392" print #moire.back, "color white; line 0 391 450 391; line 448 391 448 0" boxTitle$ = "Parameters" x = 276 y = 50 boxWidth = 158 boxHeight = 256 gosub [drawMoire3DBox] print #moire.back, "place 342, 85" print #moire.back, "\Initial X-Y" print #moire.back, "place 342, 185" print #moire.back, "\Magnification" print #moire.color, "reset" 'initiate checkboxes print #moire.back, "place 29, 333" print #moire.back, "\Color!" print #moire.back, "flush" aDefIndex = 1 'set up default index values for variables factorDefIndex = 2 dim a$(100) for i = 0 to 99 'fill variables for comboboxes a$(i) = str$(i+1) next i dim factor$(14) data$ = "0.5,1,2,3,4,5,6,7,8,9,10,15,20,25" count = 0 while data$ <> "" length = len(data$) x = instr(data$, ",") if x = 0 then factor$(count) = trim$(data$): data$ = "" : goto [getOut] factor$(count) = left$(data$, x-1) data$ = right$(data$,length-x) count = count + 1 [getOut] wend print #moire.a, "reload" 'load comboboxes print #moire.factor, "reload" print #moire.a, "selectindex "; aDefIndex 'initiate comboboxes with defaults print #moire.factor, "selectindex "; factorDefIndex [moireLoop] input aVar$ goto [moireLoop] [drawMoire] print #moire.drawing, "cls" print #moire.drawing, "down; fill lightgray; flush" ' print #moire.color, "value?" ' input #moire.color, result$ ' if result$ = "set" then colorFlag = 1 '0=off, 1 = on ' if result$ = "reset" then colorFlag = 0 ' colorFlag = 0 print #moire.a, "selection?" : input #moire.a, a$ a = val(a$) print #moire.factor, "selection?" : input #moire.factor, factor$ factor = val(factor$) gbox = 254 cx = gbox/2 cy = gbox/2 size = gbox/2 ' factor = 10 'set as range from .5 to 10 ncolors = 256 index = 0 dim c(256) for x = 0 to 255 c(index) = x + x*256 + x*65536 'create RGB values - gray scale index = index + 1 next x open "user" for dll as #user open "gdi" for dll as #gdi h=hwnd(#moire.drawing) calldll#user,"GetDC",_ h as word,_ hdc as word ' a = 1 'set from 1 to 100 x = a for i = 0 to size scan y = x for j = i to size c1 = factor * int(x ^ 2 + y ^ 2) mod = c1 - ((int(c1/256)) * 256) c2 = mod c = c(c2) xset = cx + i yset = cy + j calldll#gdi,"SetPixel",_ hdc as word,_ xset as short,_ yset as short,_ c as long,_ result as long xset = cx + j yset = cy + i calldll#gdi,"SetPixel",_ hdc as word,_ xset as short,_ yset as short,_ c as long,_ result as long xset = cx + j yset = cy - i calldll#gdi,"SetPixel",_ hdc as word,_ xset as short,_ yset as short,_ c as long,_ result as long xset = cx + i yset = cy - j calldll#gdi,"SetPixel",_ hdc as word,_ xset as short,_ yset as short,_ c as long,_ result as long xset = cx - i yset = cy - j calldll#gdi,"SetPixel",_ hdc as word,_ xset as short,_ yset as short,_ c as long,_ result as long xset = cx - j yset = cy - i calldll#gdi,"SetPixel",_ hdc as word,_ xset as short,_ yset as short,_ c as long,_ result as long xset = cx - j yset = cy + i calldll#gdi,"SetPixel",_ hdc as word,_ xset as short,_ yset as short,_ c as long,_ result as long xset = cx - i yset = cy + j calldll#gdi,"SetPixel",_ hdc as word,_ xset as short,_ yset as short,_ c as long,_ result as long y = y + a next j goto [nextI] [endMoireLoop] i = size [nextI] x = x + a next i ' cursor normal calldll#user,"ReleaseDC",h as word,hdc as word,result as ushort close #user close #gdi print #moire.drawing, "getbmp Picture "; 0; " "; 0; " "; gbox; " "; gbox print #moire.drawing, "drawbmp Picture "; 0; " "; 0 print #moire.drawing, "flush" goto [moireLoop] [saveMoireBmp] gosub [saveBmpNow] goto [moireLoop] [quitMoire] close #moire goto [mainLoop] '================================================ [saveBmpNow] notice "This feature not available yet!" return [tile.it] ' now use drawbmp graphic command to tile image onto window print #main.cells.drawing, "getbmp Picture "; 0; " "; 0; " "; bmpWide; " "; bmpHigh for x = 0 to gbox-bmpWide step bmpWide for y = 0 to gbox-bmpHigh step bmpHigh print #main.cells.drawing, "drawbmp Picture "; x; " "; y print #main.cells.drawing, "flush" next y next x return [tileWaves] ' now use drawbmp graphic command to tile image onto window print #waves.drawing, "getbmp Picture "; 0; " "; 0; " "; bmpWide; " "; bmpHigh for x = 0 to gbox-bmpWide step bmpWide for y = 0 to gbox-bmpHigh step bmpHigh print #waves.drawing, "drawbmp Picture "; x; " "; y print #waves.drawing, "flush" next y next x return [draw3DBox] ' Routine to draw a 3D box with a "title" in the top line ' x is the x position to start drawing box ' y is the y position to start drawing box ' boxWidth is the desired box width ' boxHeight is the desired box height ' boxTitle$ is the desired box "title" print #main.cells.parameters, "color darkgray ; down" print #main.cells.parameters, "place "; x; " "; y print #main.cells.parameters, "box "; boxWidth + x; " "; boxHeight+y print #main.cells.parameters, "color white" print #main.cells.parameters, "place "; x+1; " "; y+1 print #main.cells.parameters, "line "; x+1; " "; y+1; " "; x+1; " "; y+boxHeight-2 print #main.cells.parameters, "place "; x+1; " "; y+1 print #main.cells.parameters, "line "; x+1; " "; y+1; " "; x + boxWidth - 2; " "; y+1 print #main.cells.parameters, "place "; x; " "; y+boxHeight print #main.cells.parameters, "line "; x; " "; y+boxHeight; " "; x+boxWidth +1; " "; y+boxHeight print #main.cells.parameters, "place "; x+boxWidth; " "; y print #main.cells.parameters, "line "; x+boxWidth; " "; y; " "; x+boxWidth; " "; y+boxHeight+1 print #main.cells.parameters, "flush" print #main.cells.parameters, "color black" 'print text color print #main.cells.parameters, "place "; x+6; " "; y+5 'location print #main.cells.parameters, "backcolor lightgray" 'backcolor print #main.cells.parameters, "\ "; boxTitle$ + ":" 'Title of Box print #main.cells.parameters, "flush" 'flush return [drawSpheres3DBox] ' Routine to draw a 3D box with a "title" in the top line ' x is the x position to start drawing box ' y is the y position to start drawing box ' boxWidth is the desired box width ' boxHeight is the desired box height ' boxTitle$ is the desired box "title" print #spheres.back, "color darkgray ; down" print #spheres.back, "place "; x; " "; y print #spheres.back, "box "; boxWidth + x; " "; boxHeight+y print #spheres.back, "color white" print #spheres.back, "place "; x+1; " "; y+1 print #spheres.back, "line "; x+1; " "; y+1; " "; x+1; " "; y+boxHeight-2 print #spheres.back, "place "; x+1; " "; y+1 print #spheres.back, "line "; x+1; " "; y+1; " "; x + boxWidth - 2; " "; y+1 print #spheres.back, "place "; x; " "; y+boxHeight print #spheres.back, "line "; x; " "; y+boxHeight; " "; x+boxWidth +1; " "; y+boxHeight print #spheres.back, "place "; x+boxWidth; " "; y print #spheres.back, "line "; x+boxWidth; " "; y; " "; x+boxWidth; " "; y+boxHeight+1 print #spheres.back, "flush" print #spheres.back, "color black" 'print text color print #spheres.back, "place "; x+6; " "; y+5 'location print #spheres.back, "backcolor lightgray" 'backcolor print #spheres.back, "\ "; boxTitle$ + ":" 'Title of Box print #spheres.back, "flush" 'flush return [drawMoire3DBox] ' Routine to draw a 3D box with a "title" in the top line ' x is the x position to start drawing box ' y is the y position to start drawing box ' boxWidth is the desired box width ' boxHeight is the desired box height ' boxTitle$ is the desired box "title" print #moire.back, "color darkgray ; down" print #moire.back, "place "; x; " "; y print #moire.back, "box "; boxWidth + x; " "; boxHeight+y print #moire.back, "color white" print #moire.back, "place "; x+1; " "; y+1 print #moire.back, "line "; x+1; " "; y+1; " "; x+1; " "; y+boxHeight-2 print #moire.back, "place "; x+1; " "; y+1 print #moire.back, "line "; x+1; " "; y+1; " "; x + boxWidth - 2; " "; y+1 print #moire.back, "place "; x; " "; y+boxHeight print #moire.back, "line "; x; " "; y+boxHeight; " "; x+boxWidth +1; " "; y+boxHeight print #moire.back, "place "; x+boxWidth; " "; y print #moire.back, "line "; x+boxWidth; " "; y; " "; x+boxWidth; " "; y+boxHeight+1 print #moire.back, "flush" print #moire.back, "color black" 'print text color print #moire.back, "place "; x+6; " "; y+5 'location print #moire.back, "backcolor lightgray" 'backcolor print #moire.back, "\ "; boxTitle$ + ":" 'Title of Box print #moire.back, "flush" 'flush return [drawWaves3DBox] ' Routine to draw a 3D box with a "title" in the top line ' x is the x position to start drawing box ' y is the y position to start drawing box ' boxWidth is the desired box width ' boxHeight is the desired box height ' boxTitle$ is the desired box "title" print #waves.parameters, "color darkgray ; down" print #waves.parameters, "place "; x; " "; y print #waves.parameters, "box "; boxWidth + x; " "; boxHeight+y print #waves.parameters, "color white" print #waves.parameters, "place "; x+1; " "; y+1 print #waves.parameters, "line "; x+1; " "; y+1; " "; x+1; " "; y+boxHeight-2 print #waves.parameters, "place "; x+1; " "; y+1 print #waves.parameters, "line "; x+1; " "; y+1; " "; x + boxWidth - 2; " "; y+1 print #waves.parameters, "place "; x; " "; y+boxHeight print #waves.parameters, "line "; x; " "; y+boxHeight; " "; x+boxWidth +1; " "; y+boxHeight print #waves.parameters, "place "; x+boxWidth; " "; y print #waves.parameters, "line "; x+boxWidth; " "; y; " "; x+boxWidth; " "; y+boxHeight+1 print #waves.parameters, "flush" print #waves.parameters, "color black" 'print text color print #waves.parameters, "place "; x+6; " "; y+5 'location print #waves.parameters, "backcolor lightgray" 'backcolor print #waves.parameters, "\ "; boxTitle$ + ":" 'Title of Box print #waves.parameters, "flush" 'flush return