' Demo1: Drawbmp with native LB Commands Nomainwin WindowWidth = 600 WindowHeight = 400 Graphicbox #w.g1, 10, 10, 102, 102 Statictext #w.st1a, "Image Source", 8, 120, 110, 32 Graphicbox #w.g2, 140, 10, 440, 119 Statictext #w.st2a, "Image transferred from bitmap in memory using Liberty BASIC native commands", 138, 140, 440, 16 Statictext #w.st2b, "Getbmp, Drawbmp, Flush", 138, 156, 440, 16 ' Open the Window Open "Demo" For Window as #w #w "Trapclose EndProgram" #w.g2 "Horizscrollbar On 0 760" ' Display Solid Backgrounds Call hueBackground "#w.g1", "Darkgreen" Call hueBackground "#w.g2", "Darkgreen" ' Draw the house bitmap in the left graphicbox and capture it with Getbmp Call SimpleHouse "#w.g1", 0, 0 #w.g1 "Getbmp SimpleHouse 0 0 100 100" #w.g1 "Flush" ' Create a row of houses with a series of Drawbmp commands For x = 0 to 1200 Step 100 #w.g2 "Drawbmp SimpleHouse ";x;" 0" Next x ' Flush the Display #w.g2 "Flush" ' Unload the bitmap to free memory Unloadbmp "SimpleHouse" Wait Sub EndProgram handle$ Close #w End End Sub Sub hueBackground handle$, hue$ #handle$ "Down; Fill ";hue$ #handle$ "Flush; Discard" End Sub Sub SimpleHouse handle$, xLoc, yLoc Call hueBackground handle$, "Darkblue" #handle$ "Color 128 64 0; Backcolor Brown" #handle$ "Place ";xLoc + 5;" ";yLoc + 50 #handle$ "Boxfilled ";xLoc + 95;" ";yLoc + 90 For x = xLoc to xLoc + 100 #handle$ "Line ";xLoc + 50;" ";y + 10;" ";x;" ";y + 50 Next x #handle$ "Backcolor 128 64 0" #handle$ "Place ";xLoc + 10;" ";yLoc + 60 #handle$ "Boxfilled ";xLoc + 30;" ";yLoc + 80 #handle$ "Place ";xLoc + 65;" ";yLoc + 60 #handle$ "Boxfilled ";xLoc + 85;" ";yLoc + 80 #handle$ "Place ";xLoc + 35;" ";yLoc + 70 #handle$ "Boxfilled ";xLoc + 60;" ";yLoc + 90 #handle$ "Color 16 16 16; Backcolor 16 16 16" #handle$ "Place ";xLoc;" ";yLoc + 90 #handle$ "Boxfilled ";xLoc + 100;" ";yLoc + 100 Call SimpleGrass handle$, xLoc, yLoc End Sub Sub SimpleGrass handle$, xLoc, yLoc For x = xLoc to xLoc + 100 greenHue = Int(Rnd(1) * 128) + 16 #handle$ "Color 0 ";greenHue;" 0" y = Int(Rnd(1) * 10) + 85 #handle$ "Line ";x;" ";y;" ";x;" 100" Next x End Sub
You need to enable Javascript in your browser to edit pages.
help on how to format text