Graphics 800,600,16,2SeedRnd MilliSecs()Global cols# = 800 rows# = 600Dim num(Cols)Foil(cols#,rows#) ;change this to what u wantFunction Grass(cols#,rows#)For x = 0 To cols Step 1 For y = 0 To rows# Step 1 Color 0,Rand(0,200),0 Plot x,yNextNextSaveBuffer(FrontBuffer(),"grass.bmp")End FunctionFunction Foil(cols#,rows#)For x = 0 To cols Step 1 For y = 0 To rows# Step 1 Color Rand(0,255),Rand(0,256),Rand(0,256) Plot x,yNextNextSaveBuffer(FrontBuffer(),"foil.bmp")End FunctionFunction Blue(cols#,rows#)For x = 0 To cols# Step 1 For y = 0 To rows# Step 1 Color Rand(0,200),Rand(0,200),255 Plot x,yNextNextSaveBuffer(FrontBuffer(),"blue.bmp")End FunctionFunction Red(cols#,rows#)For x = 0 To cols# Step 1 For y = 0 To rows# Step 1 Color Rand(0,200),0,0 Plot x,yNextNextSaveBuffer(FrontBuffer(),"red.bmp")End FunctionEnd
Graphics 800,600,16,2SeedRnd MilliSecs()cols# = 800 rows# = 600 ;changed the vars to var#s just so we're clear these are NUMBERS and not STRINGS. It's good ettiquite. ;)NoiseColor$ = "ColorTV" ;This is the part you change. Must be set to either "Grass" , "Foil" , "Blue" , "Red" , or new ColorTV! :)Dim num(Cols)Noise(cols#,rows#,NoiseColor$) Function Noise(cols#,rows#,NoiseColor$)For x = 0 To cols Step 1 For y = 0 To rows# Step 1Select NoiseColor$ ;here I used a SELECT/CASE/DEFAULT/END SELECT command here rather than mucking about with all the if statements it would take. Look up "case" in the Blitz command reference for more info. ;)Case "Grass" Color 0,Rnd(0,256),0Case "Foil" GreyColor# = Rnd(0,255) Color GreyColor# , GreyColor# , GreyColor# Case "ColorTV" Color Rnd(0,255),Rnd(0,256),Rnd(0,256)Case "Blue" Color 0,0,Rnd(0,256)Case "Red" Color Rnd(0,255),0,0End Select Plot x,yNextNextSaveBuffer(FrontBuffer(), NoiseColor$ + ".bmp") ;Here we see how easy it is to turn a string variable into a filename. Just literally add the file extention to the string. (I wasn't actually sure this would work until I tried it. :P )End FunctionEnd
Graphics 800,600,16,2SeedRnd MilliSecs();No need to declare values here! We'll be obtaining them from the user with INPUT statements!cols# =Input$("Image Height?")rows# =Input$("Image Width?")Dim num(Cols)Filename$=Input$("What should we call this image?")Greyscale$=Input$("Is the image Greyscale? (y/n)")If Greyscale$ = "y"MinR# = Input$("Minimum Brightness? (0-255)")MaxR# = Input$("Maximum Brightness? (0-255)")Noise(cols#,rows#,Filename$,Greyscale$,MinR#,MaxR#,0,0,0,0)Else If Greyscale$ = "n"MinR# = Input$("Minimum Red? (0-255)")MaxR# = Input$("Maximum Red? (0-255)")MinB# = Input$("Minimum Blue? (0-255)")MaxB# = Input$("Maximum Blue? (0-255)")MinG# = Input$("Minimum Green? (0-255)")MaxG# = Input$("Maximum Green? (0-255)")Noise(cols#,rows#,Filename$,Greyscale$,MinR#,MaxR#,MinB#,MaxB#,MinG#,MaxG#) End IfEndFunction Noise(cols#,rows#,Filename$,Greyscale$,MinR#,MaxR#,MinB#,MaxB#,MinG#,MaxG#) For x = 0 To cols Step 1For y = 0 To rows# Step 1Select Greyscale$Case "y" GreyColor# = Rnd(MinR#,MaxR#) Color GreyColor# , GreyColor# , GreyColor# Case "n" Color Rnd(MinR#,MaxR#),Rnd(MinG#,MaxG#),Rnd(MinB#,MaxB#)End Select Plot x,yNextNextSaveBuffer(FrontBuffer(), Filename$ + ".bmp") End Function
Graphics 800,600,16,2SeedRnd MilliSecs();No need to declare variables here! We'll be obtaining them from the user with INPUT statements! cols# =Input$("Image Height?")rows# =Input$("Image Width?")Dim num(Cols#)Filename$=Input$("What should we call this image?")Greyscale$=Input$("Is the image Greyscale? (y/n)")If Greyscale$ = "y"MinR# = Input$("Minimum Brightness? (0-255)")MaxR# = Input$("Maximum Brightness? (0-255)")Noise(cols#,rows#,Filename$,Greyscale$,MinR#,MaxR#,0,0,0,0)Else If Greyscale$ = "n"MinR# = Input$("Minimum Red? (0-255)")MaxR# = Input$("Maximum Red? (0-255)")MinB# = Input$("Minimum Blue? (0-255)")MaxB# = Input$("Maximum Blue? (0-255)")MinG# = Input$("Minimum Green? (0-255)")MaxG# = Input$("Maximum Green? (0-255)")Noise(cols#,rows#,Filename$,Greyscale$,MinR#,MaxR#,MinB#,MaxB#,MinG#,MaxG#) End IfEndFunction Noise(cols#,rows#,Filename$,Greyscale$,MinR#,MaxR#,MinB#,MaxB#,MinG#,MaxG#) MyTexture=CreateImage(cols#,rows#) ;MyTexture is a variable name. CreateImage creates a new image within texture memory, just like a texture in a 3D game. At first, it's a blank image, but...SetBuffer ImageBuffer(MyTexture) ; By setting our new image as a buffer, we can draw to it instead of directly to the screen! :DFor x = 0 To cols Step 1For y = 0 To rows# Step 1Select Greyscale$Case "y" GreyColor# = Rnd(MinR#,MaxR#) Color GreyColor# , GreyColor# , GreyColor# Case "n" Color Rnd(MinR#,MaxR#),Rnd(MinG#,MaxG#),Rnd(MinB#,MaxB#)End SelectPlot x,yNextNextSaveBuffer (ImageBuffer(MyTexture), Filename$ + ".bmp") ; Now we just save our buffer instead of FrontBuffer! Easy! :DEnd Function