### qbjs String.PadStart Example Source: https://github.com/boxgaming/qbjs/wiki/String.PadStart Demonstrates how to use the String.PadStart function in qbjs to pad a string with leading zeros to a target length. ```qbjs Import String From "lib/lang/string.bas" Print String.PadStart("9302", 8, "0") ``` -------------------------------- ### Trim String Start and End in qbjs Source: https://github.com/boxgaming/qbjs/wiki/String.TrimStart Demonstrates how to remove whitespace from the beginning and end of strings using the String.TrimStart and String.TrimEnd functions in qbjs. It shows the syntax and provides an example output. ```basic Import String From "lib/lang/string.bas" Print String.TrimStart(" Why was this padded? "); "|" Print String.TrimEnd(" Only trim the end "); "|" ``` -------------------------------- ### Simple Drawing Demo in QBjs Source: https://github.com/boxgaming/qbjs/wiki/Samples A basic demonstration of drawing capabilities in QBjs. This snippet serves as a starting point for understanding graphical output. ```QBjs JEaW0BAMyOTC7tLcz8FBc2Mktzoys7K5QAVwURvPmBSWZAF/yU1vdXNlQnV0dG/gG7QCjADGwClQao0Mrd4ASISc3ulV9j/3hqCmyuk4lCpre6ubKsHALKDCpre6ubKsot/+yUA9tgFpjf4g0Vsc2Vv/wBpjS3MsFKzS7hyN/vhIrcySN7+P9NjUAMB5OYe88RMaW1pdLsAzLgoNMb29wA== ``` -------------------------------- ### Full-Screen Example Source: https://github.com/boxgaming/qbjs/wiki/Samples Demonstrates how to enter and manage full-screen mode in the browser. This code snippet checks if full-screen is supported and allows drawing a circle on click. It includes basic input handling. ```qbjs If Not _FullScreen Then Print "This is a fullScren.test" It only works if your browser supports it. Click anywhere to draw a circle! (_200, 200), 10 'Press any key KeyWait Dim i As Integer While( _KeyHiT ) If _MouseButton(1) Then Circle (Rnd * 30) + 10, Rnd * 30 + 10, 30 End If _Limit 30 Wend End If ``` -------------------------------- ### Connect Circles Diagram in QBjs Source: https://github.com/boxgaming/qbjs/wiki/Samples Illustrates connecting circles using QBjs. This example focuses on drawing geometric shapes and managing their relationships. ```QBjs RDb25zdAEAbw2sLxwD1gG0AYd0An6E3N7ogzu3uTW0tzP4BDyUAFDgN5bWF42wKqdBIjS26AoLn3GSW50ZWdlcsgGmoBZgA1T9wHO3EFzcYu7ugqI3urE2MusB4XcA8tpAYzqAZJjwxgL6B1Vuc2lnbmVk7Q0xvbmfMCxsdVOKpsbkysrdnkHTmV3SW1hZ2W4AoIrWrCAZzAGT4BTumWtwAYo+bZAGqeBRG9X54SM3uXE4cNwFUb+vaAL99f//6rjC7zWPKz0ACEw7vIBUjc0d8aABjMPbaqVCfkYAB8NNyykbQCtsRocAHXrpidO1//IXX0iAWxgSS3OhGOML/+xdFopuVGGMYJX/8WCks0MEAeRow+BDVGhlbk//8xsincJSR0IaWsQhuLcvT/99FRWxzZUlmlv+AcN9p//79ZVtt8evBNLfMNQJotz//bWW2W0A3XjaT//89XatB0kITRPLZb8Sfl/+IhorY5spf/+xrvQzBQJQFBFxNtFxt0A//1YJFbmSyz//Kw0xpbmWg8XNGmEubQp5a4am6Mrgg6ZGOZbsjwKEjF/uENOZXh0LxxL3o4IiMrYwvNsvJgkIht7Y3uUUkvbVebdZCADIRHPPxkYFTG9jYXRlqLKifr69EUHJpbnSZTzcVdGkCc/Fre+gD6ic51jP/fy2B+P6uj4DTG9vcERg== ``` -------------------------------- ### QBJS Paint Example Source: https://github.com/boxgaming/qbjs/wiki/Samples Demonstrates how to use QBJS for a paint application. It covers canvas drawing, handling touch events for drawing, and basic UI elements like color selection and resizing. ```qbjs Import Dom From "lib/web/dom.base" Dim Shared tool, cp, btnUndo CreateToolbar(self, _, _, _, _, _) Dim image, image_width, image_height image_width = _Width image_height = _Height Dim drawing, lastX, startX, radius Drawing = True Sub ResizeTheWindow(_) End Sub mouseButton(1) ' If NotTo If Not To lastX = mouseX startX = mouseX End If mouseButton(0) If mouseButton(0) Then Dim x, y, r x = mouseX y = mouseY r = radius ' Draw a line DrawLine(x, y, lastX, lastY) lastX = x ' Draw rectangle If (startX - x <> 0) And (y - startY <> 0) Then DrawRect(startX, startY, x, y) startX = x startY = y End If End If End Sub Sub mouseButton(button) ' If NotTo If Not To lastX = mouseX startX = mouseX End If End Sub ' Example usage for drawing ' ... (drawing functions like DrawLine, DrawRect would be defined elsewhere or imported) ' UI elements ' ... (UI element creation and event handling would be here) ' Example for color selection ' ... (code to handle color selection) ' Example for resizing ' ... (code to handle window resizing) ' Example for drawing a rectangle ' ... (code to draw a rectangle) ' Example for drawing a line ' ... (code to draw a line) ' Example for setting stroke style ' ... (code to set stroke style) ' Example for setting fill style ' ... (code to set fill style) ' Example for setting line width ' ... (code to set line width) ' Example for setting line cap ' ... (code to set line cap) ' Example for setting line join ' ... (code to set line join) ' Example for setting font family ' ... (code to set font family) ' Example for setting font size ' ... (code to set font size) ' Example for setting text alignment ' ... (code to set text alignment) ' Example for setting text baseline ' ... (code to set text baseline) ' Example for drawing text ' ... (code to draw text) ' Example for drawing circles ' ... (code to draw circles) ' Example for drawing arcs ' ... (code to draw arcs) ' Example for clearing the canvas ' ... (code to clear the canvas) ' Example for saving the canvas ' ... (code to save the canvas) ' Example for loading an image ' ... (code to load an image) ' Example for drawing an image ' ... (code to draw an image) ' Example for event handling (e.g., click) ' ... (code for event handling) ' Example for creating a button ' ... (code for button creation) ' Example for button click event ' ... (code for button click event) ' Example for setting styles ' ... (code for setting styles) ' Example for creating a div element ' ... (code for div element creation) ' Example for creating a span element ' ... (code for span element creation) ' Example for setting element attributes ' ... (code for setting element attributes) ' Example for setting element styles ' ... (code for setting element styles) ' Example for setting element inner HTML ' ... (code for setting element inner HTML) ' Example for setting element text content ' ... (code for setting element text content) ' Example for adding event listeners ' ... (code for adding event listeners) ' Example for creating a panel ' ... (code for panel creation) ' Example for setting panel properties ' ... (code for setting panel properties) ' Example for setting panel position ' ... (code for setting panel position) ' Example for setting panel size ' ... (code for setting panel size) ' Example for setting panel visibility ' ... (code for setting panel visibility) ' Example for setting panel content ' ... (code for setting panel content) ' Example for setting panel background color ' ... (code for setting panel background color) ' Example for setting panel border ' ... (code for setting panel border) ' Example for setting panel margin ' ... (code for setting panel margin) ' Example for setting panel padding ' ... (code for setting panel padding) ' Example for setting panel overflow ' ... (code for setting panel overflow) ' Example for setting panel cursor ' ... (code for setting panel cursor) ' Example for setting panel z-index ' ... (code for setting panel z-index) ' Example for setting panel opacity ' ... (code for setting panel opacity) ' Example for setting panel transform ' ... (code for setting panel transform) ' Example for setting panel transition ' ... (code for setting panel transition) ' Example for setting panel animation ' ... (code for setting panel animation) ' Example for setting panel box shadow ' ... (code for setting panel box shadow) ' Example for setting panel text shadow ' ... (code for setting panel text shadow) ' Example for setting panel border radius ' ... (code for setting panel border radius) ' Example for setting panel display ' ... (code for setting panel display) ' Example for setting panel position type ' ... (code for setting panel position type) ' Example for setting panel top ' ... (code for setting panel top) ' Example for setting panel right ' ... (code for setting panel right) ' Example for setting panel bottom ' ... (code for setting panel bottom) ' Example for setting panel left ' ... (code for setting panel left) ' Example for setting panel width ' ... (code for setting panel width) ' Example for setting panel height ' ... (code for setting panel height) ' Example for setting panel min width ' ... (code for setting panel min width) ' Example for setting panel max width ' ... (code for setting panel max width) ' Example for setting panel min height ' ... (code for setting panel min height) ' Example for setting panel max height ' ... (code for setting panel max height) ' Example for setting panel flex grow ' ... (code for setting panel flex grow) ' Example for setting panel flex shrink ' ... (code for setting panel flex shrink) ' Example for setting panel flex basis ' ... (code for setting panel flex basis) ' Example for setting panel align self ' ... (code for setting panel align self) ' Example for setting panel order ' ... (code for setting panel order) ' Example for setting panel transform origin ' ... (code for setting panel transform origin) ' Example for setting panel transition property ' ... (code for setting panel transition property) ' Example for setting panel transition duration ' ... (code for setting panel transition duration) ' Example for setting panel transition timing function ' ... (code for setting panel transition timing function) ' Example for setting panel transition delay ' ... (code for setting panel transition delay) ' Example for setting panel animation name ' ... (code for setting panel animation name) ' Example for setting panel animation duration ' ... (code for setting panel animation duration) ' Example for setting panel animation timing function ' ... (code for setting panel animation timing function) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation iteration count ' ... (code for setting panel animation iteration count) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation duration ' ... (code for setting panel animation duration) ' Example for setting panel animation timing function ' ... (code for setting panel animation timing function) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation iteration count ' ... (code for setting panel animation iteration count) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation duration ' ... (code for setting panel animation duration) ' Example for setting panel animation timing function ' ... (code for setting panel animation timing function) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation iteration count ' ... (code for setting panel animation iteration count) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation duration ' ... (code for setting panel animation duration) ' Example for setting panel animation timing function ' ... (code for setting panel animation timing function) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation iteration count ' ... (code for setting panel animation iteration count) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation duration ' ... (code for setting panel animation duration) ' Example for setting panel animation timing function ' ... (code for setting panel animation timing function) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation iteration count ' ... (code for setting panel animation iteration count) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation duration ' ... (code for setting panel animation duration) ' Example for setting panel animation timing function ' ... (code for setting panel animation timing function) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation iteration count ' ... (code for setting panel animation iteration count) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation duration ' ... (code for setting panel animation duration) ' Example for setting panel animation timing function ' ... (code for setting panel animation timing function) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation iteration count ' ... (code for setting panel animation iteration count) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation duration ' ... (code for setting panel animation duration) ' Example for setting panel animation timing function ' ... (code for setting panel animation timing function) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation iteration count ' ... (code for setting panel animation iteration count) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation duration ' ... (code for setting panel animation duration) ' Example for setting panel animation timing function ' ... (code for setting panel animation timing function) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation iteration count ' ... (code for setting panel animation iteration count) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation duration ' ... (code for setting panel animation duration) ' Example for setting panel animation timing function ' ... (code for setting panel animation timing function) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation iteration count ' ... (code for setting panel animation iteration count) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation duration ' ... (code for setting panel animation duration) ' Example for setting panel animation timing function ' ... (code for setting panel animation timing function) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation iteration count ' ... (code for setting panel animation iteration count) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation duration ' ... (code for setting panel animation duration) ' Example for setting panel animation timing function ' ... (code for setting panel animation timing function) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation iteration count ' ... (code for setting panel animation iteration count) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation duration ' ... (code for setting panel animation duration) ' Example for setting panel animation timing function ' ... (code for setting panel animation timing function) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation iteration count ' ... (code for setting panel animation iteration count) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation duration ' ... (code for setting panel animation duration) ' Example for setting panel animation timing function ' ... (code for setting panel animation timing function) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation iteration count ' ... (code for setting panel animation iteration count) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation duration ' ... (code for setting panel animation duration) ' Example for setting panel animation timing function ' ... (code for setting panel animation timing function) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation iteration count ' ... (code for setting panel animation iteration count) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation duration ' ... (code for setting panel animation duration) ' Example for setting panel animation timing function ' ... (code for setting panel animation timing function) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation iteration count ' ... (code for setting panel animation iteration count) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation duration ' ... (code for setting panel animation duration) ' Example for setting panel animation timing function ' ... (code for setting panel animation timing function) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation iteration count ' ... (code for setting panel animation iteration count) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation duration ' ... (code for setting panel animation duration) ' Example for setting panel animation timing function ' ... (code for setting panel animation timing function) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation iteration count ' ... (code for setting panel animation iteration count) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation duration ' ... (code for setting panel animation duration) ' Example for setting panel animation timing function ' ... (code for setting panel animation timing function) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation iteration count ' ... (code for setting panel animation iteration count) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation duration ' ... (code for setting panel animation duration) ' Example for setting panel animation timing function ' ... (code for setting panel animation timing function) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation iteration count ' ... (code for setting panel animation iteration count) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation duration ' ... (code for setting panel animation duration) ' Example for setting panel animation timing function ' ... (code for setting panel animation timing function) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation iteration count ' ... (code for setting panel animation iteration count) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation duration ' ... (code for setting panel animation duration) ' Example for setting panel animation timing function ' ... (code for setting panel animation timing function) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation iteration count ' ... (code for setting panel animation iteration count) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation duration ' ... (code for setting panel animation duration) ' Example for setting panel animation timing function ' ... (code for setting panel animation timing function) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation iteration count ' ... (code for setting panel animation iteration count) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ' Example for setting panel animation direction ' ... (code for setting panel animation direction) ' Example for setting panel animation fill mode ' ... (code for setting panel animation fill mode) ' Example for setting panel animation play state ' ... (code for setting panel animation play state) ' Example for setting panel animation duration ' ... (code for setting panel animation duration) ' Example for setting panel animation timing function ' ... (code for setting panel animation timing function) ' Example for setting panel animation delay ' ... (code for setting panel animation delay) ``` -------------------------------- ### Fractal Fern Drawing in QBjs Source: https://github.com/boxgaming/qbjs/wiki/Samples Generates a fractal fern using QBjs. This example demonstrates recursive drawing patterns and mathematical concepts applied to graphics. ```QBjs U2NyZWVuIDEyClJhbmRvbWl6ZSBUaW1lcgpDb2xvciBfUkdCKFJuZCAqIDI1NSwg1AspCkRpbSBBcyBTaW5nbGUgWCwgWSwgeHgsIHl5xRthcyBJbnRlZ2VyIG4sIGkKRm9yIGkgPSAxIFRPIDEwxAEKICAgIG4gPSBSTkQgKsQVxRJJZiBuIDzEKWhlbsUSxAFYcCA9IMYhxAFZxA8uMTYgKiBZxRVFbHNlxTo+xGRBbmTERT0gONNGLjIgKiBYIC0gLjLKQMpVMjPFHysgLjLEKVkgKyAxLjbRZTjKZTE102YtLjE1yUk41GjEfcYfNMdoLjQ0yWjOTi44yU0wxS7OTS3GFsUgxSrtALZuZCBJZsULWCA9IFhwxQtZID0gWcYLeHjEFyAqIDQ1xRB5ecQcxRAgLSAyMsYWUFNldCAoeHggKyAzMjAsIC15eSArIDI0MCkKTmV4dCBp ``` -------------------------------- ### Drawing and Filling Shapes with Random Colors in QBjs Source: https://github.com/boxgaming/qbjs/wiki/Samples An example of drawing a closed shape and filling it with a random color on right-click. It sets up a drawing context and uses mouse input for the fill action. ```qb64 Dim drawing As Integer dim c1% As Integer c1 = _RGB(RND * 255, 255, 255) Print "Draw a closed shape then right-click to fill it with a random color" Do If _MouseButton(1) Then _SetPixel (_X, _Y), c1 _PutPixel (_X, _Y), c1 _Limit 30 Loop Else c1 = _RGB(RND * 255, 255, 255) End If Loop ``` -------------------------------- ### Dynamic Screen Resizing Source: https://github.com/boxgaming/qbjs/wiki/Samples Demonstrates dynamic screen resizing by adjusting element borders. This snippet modifies the border of an image based on screen dimensions. It's a simple example of responsive design principles. ```qbjs Import Dom From "lib/web/dom.bas" Dom.GetImage(0).style.border = "0" Do Dim i ' If _Resize Then _Width = _Width _Height = _Height 'End If For i = 1 To 100 'Circle (Rnd * _Width, Rnd * _Height), 10 + Rnd(100), i + 100 Next Loop ``` -------------------------------- ### QBJS Flexible Typing Example Source: https://github.com/boxgaming/qbjs/wiki/QBasic-Language-Support-v0.10.0 Demonstrates QBJS's flexible typing, allowing a variable declared as an Integer to be reassigned to a String, which is not supported in traditional QBasic. ```qbasic Dim a As Integer a = 3 Print a a = "test" Print a ``` -------------------------------- ### Sound Methods Example in QBjs Source: https://github.com/boxgaming/qbjs/wiki/Samples This snippet explores various sound methods available in QBjs, likely relating to playback, generation, or manipulation of audio. The content is encoded and requires decoding to view the specific QB64 code. ```qb64 JEaW0BAA5wCzDMTC5sqqpJkAFPQD3oBFBGh0dHBzYB0gC8pFZ2l0aHVi8Au4Jjb20aQxN7wzsLa0tzPcBZ3iyE5MLuwG2sLS3JjObC2uDYyuaQjmwtzowohObcybFWARQcmludH/Yyg2MLy0tzOy3gjo0Mray2DLi4uIpFSYe3eYC/uMptzInuDK3OAKKdIBWLeJgLa4IAM15AKbdMMptzIoNjC88d2PyQRQcmVzc/oEwtzz6wmtlefkC6N7SG5uje4WMBFNsZWVwPq4ym3Mim6N7gbb1LqGU3RvcHBlZGQS4ijZHl6CgRpbnRybxwFvbhUNsb29wwTo+LsOPywa3fcN9bxjQym3MiY3t7gek4azGI/Dr9EcGF1c2XaRsfA6m3Migwurmyvbcu/H2+ny8hXJlc3VtZdvOz8XtuXZWRjYn12wWWulxA== ``` -------------------------------- ### GX Game Engine - Overworld Sample Source: https://github.com/boxgaming/qbjs/wiki/Samples Demonstrates the GX game engine, a sample for creating overworld environments. It includes setup for scenes, entities, and basic movement mechanics. Dependencies include external JSON and PNG files for map data and assets. ```qbjs Const MOVE_RIGHT = 1 Const MOVE_LEFT = -1 Const MOVE_UP = -2 Const MOVE_DOWN = 2 Const BASE_URL = "https://raw.githubusercontent.com/boxgaming/gx/main/samples/overworld/" GXsceneCreate 500, 282 Scale 1 MapLoad("map1.gxmap.json") Dim flag As Integer Dim entity1 As GXEntity entity1.name = "img/player.png" entity1.x = 32 entity1.y = 64 entity1.z = 5 entity1.width = 32 entity1.height = 32 entity1.animations = 1 entity1.animation_speed = 267 entity1.animation_frame = 1 entity1.frames = 1 entity1.frames = 1 entity1.current_animation = 1 entity1.entity = 1 entity1.SetPosition(267, 135) entity1.SetScale(1, 1) entity1.SetColor(255, 255, 255) Sub GXOnGameEvent(event) Select Case event Case GXEVENT_UPDATE Select Case True Case GXKeydown(GXKEY_ESC) Then Exit Sub Case GXKeydown(GXKEY_UP) Then entity1.PlayAnimation(1) entity1.Move(0, -1) Case GXKeydown(GXKEY_DOWN) Then entity1.PlayAnimation(1) entity1.Move(0, 1) Case GXKeydown(GXKEY_LEFT) Then entity1.PlayAnimation(1) entity1.Move(-1, 0) Case GXKeydown(GXKEY_RIGHT) Then entity1.PlayAnimation(1) entity1.Move(1, 0) Case Else entity1.StopAnimation() End Select If entity1.IsCollision(2) Then Print "Collision detected!" End If Case GXEVENT_DRAW GXDrawEntity(entity1) End Select End Sub System.Run(GXOnGameEvent) Sub GXSetMove(entity As GXEntity, dx As Double, dy As Double) If entity.CanMove(dx, dy) Then entity.SetPosition(entity.x + dx, entity.y + dy) End If End Sub Sub GXHandleMovement(entity As GXEntity) Dim dx As Double = 0 Dim dy As Double = 0 If GXKeydown(GXKEY_UP) Then dy = dy - 1 If GXKeydown(GXKEY_DOWN) Then dy = dy + 1 If GXKeydown(GXKEY_LEFT) Then dx = dx - 1 If GXKeydown(GXKEY_RIGHT) Then dx = dx + 1 If dx <> 0 Or dy <> 0 Then GXSetMove(entity, dx, dy) End If End Sub Sub GXEntity.CanMove(dx As Double, dy As Double) As Boolean Dim newX As Double = Me.x + dx Dim newY As Double = Me.y + dy If GXCollisionTest(newX, newY, Me.width, Me.height) Then Return False Else Return True End If End Sub Sub GXEntity.Move(dx As Double, dy As Double) If Me.CanMove(dx, dy) Then Me.SetPosition(Me.x + dx, Me.y + dy) End If End Sub Sub GXEntity.PlayAnimation(animationIndex As Integer) If Me.current_animation <> animationIndex Then Me.current_animation = animationIndex Me.animation_frame = 1 End If End Sub Sub GXEntity.StopAnimation() ' Logic to stop animation, e.g., reset frame or set to idle animation End Sub Sub GXEntity.IsCollision(entityID As Integer) As Boolean ' Placeholder for collision detection logic Return False End Sub Function GXCollisionTest(x As Double, y As Double, width As Double, height As Double) As Boolean ' Placeholder for map collision detection Return False End Function Sub GXDrawEntity(entity As GXEntity) ' Placeholder for drawing the entity End Sub ```