Tauon Basic Script v0.94




Code Examples

/Games/dippit.tbs
/Games/dino.tbs
/Games/fruits.tbs
/Games/flags.tbs
/Games/froggy.tbs
/Sketches/aquanaut.tbs
/Sketches/sabrewulf.tbs
/Sketches/ascii_movie.tbs
/Sketches/boulderdash.tbs
/Sketches/dave.tbs
/Sketches/high_noon.tbs
/Sketches/mario.tbs
/Sketches/ninja.tbs
alphabet.tbs
animals.tbs
canvas_drawing.tbs
piano.tbs
beethoven_fur_elise.tbs
beethoven_ode_to_joy.tbs
dialog.tbs
frere_gustav.tbs
ascii.tbs
astronaut.tbs
knight.tbs
lines.tbs
little_star.tbs
london_bridge.tbs
mandelbrot.tbs
matrix_worm.tbs
maze.tbs
paint.tbs
pattern.tbs
santas_ZX_C64.tbs
sprites_from_binary.tbs
sprites_from_text.tbs


Click on a file to open it.





Screen

global object and functions related to resolution

Properties:

width
: Number. Width in pixels.
height
: Number. Height in pixels.
mouseX
: Number. Horizontal position in screen coordinates of the Mouse cursor.
mouseY
: Number. Vertical position in screen coordinates of the Mouse cursor.
randX
: Number. Random horizontal position on the Screen.
randY
: Number. Random vertical position on the Screen.

Example:




Function
setScreenMode
or
Screen.setMode
(mode)

Parameters:

mode : Number or String. Predefined screen modes:
0 - 320x180
1 - 640x360
2 - 1280x720 (default)
3 - 1920x1080
"ZX" - 256x192
"WZX" - 336x192
"ZX81" - 64x48
"CGA" - 320x200
"EGA" - 640x350
"VGA" - 640x480

Example:




Function
setScreenSize
or
Screen.setSize
(width,height)

Set custom screen resolution.

Parameters:

width : Number. Width in pixels.
height : Number. Height in pixels.



Function
clearScreen
or
Screen.clear
(color="#000")

Clear the whole screen. All Sprites and Sprite groups would be detached (but not destroyed) from Screen. Clears Console and Canvas, resets their positions and styles.

Parameters:

color : String. Color value. English color name ("yellow","red") or hex format (short "#F90" or long "#FF0000") allowed. Optional parameter. If omitted equals to "#000".



Function
setBgColor
or
Screen.setBgColor
(color="#000")

Set the background color. Resets Canvas position and style.

Parameters:

color : String. Color value. English color name ("yellow","red") or hex format (short "#F90" or long "#FF0000") allowed. Optional parameter. If omitted equals to "#000".



Function
setBorderColor
or
Screen.setBorderColor
(color="#000")

Set border color. Border is visible in some resolutions, when aspect ratio of the virtual Screen doesn't correspond to the physical one.

Parameters:

color : String. Color value. English color name ("yellow","red") or hex format (short "#F90" or long "#FF0000") allowed. Optional parameter. If omitted equals to "#000".

Example:




Function
isScreenChild
or
Screen.isChild
(node)

Return true if provided node is attached to Screen, false otherwise.

Parameters:

node : Object. Could be Sprite, SpriteGroup or HTMLElement object.

Returns:

Boolean.



Function
appendScreenChild
or
Screen.appendChild
(node)

This function attaches node to the Screen.

Parameters:

node : Object. Could be Sprite, SpriteGroup or HTMLElement object.



Function
removeScreenChild
or
Screen.removeChild
(node)

This function detaches node from the Screen.

Parameters:

node : Object. Could be Sprite, SpriteGroup or HTMLElement object.





Console

global object and functions related to text output

Properties:

value
: String. Console buffer representation as String. Would be re-built from buffer on the next frame if set to null.
buffer
: Array. Characters in the Console buffer. If buffer is modified from the code, call Console.update() in order to rebuild the Console image on the next drawing frame.
space
: Current character, used to fill holes in the Console buffer. Is set upon Console font change. Will equeal to EM Space character for Emoji font or regular Space character for any other.



Function
cls
or
clearConsole
or
Console.clear
()

Clear consoLe Screen buffer.



Function
input
or
Console.input
(text='',callback=null)

Outputs text prompt to the Console buffer and waits for user input. If callback is not set, onInput function would be called (if defined).

Parameters:

text : String. Optional parameter. If omitted equals to ''.
callback : Function reference. Function to call when operation is completed. Optional parameter. If omitted equals to null.

Example:




Function
print
or
Console.print
(...)

Output concatenated parameters to the new line in the Console buffer.

Parameters:

any number of parameters, separated by coma.

Example:




Function
printAt
or
Console.printAt
(px,py,...)

Output the text to the Console buffer at the given coordinates. Multiline text (divided with \n) is supported. Alternatively, the third parameter could be a two-dimensional array.

Parameters:

px : Number. Horizontal position coordinate.
py : Number. Vertical position coordinate.
any number of parameters, separated by coma.



Function
scan
or
Console.scan
()

Get current Console buffer content as string.

Returns:

String.



Function
scanAt
or
Console.scanAt
(px,py,sw=1,sh=1,asArray=false)

Retrieve part of the current Console buffer content at given coordinates, of width and height provided. If asArray parameter is true the result would be a two-dimensional Array, multiline String otherwise.

Parameters:

px : Number. Horizontal position coordinate.
py : Number. Vertical position coordinate.
sw : Optional parameter. If omitted equals to 1.
sh : Optional parameter. If omitted equals to 1.
asArray : Boolean. Optional parameter. If omitted equals to false.



Function
setConsoleFont
or
Console.setFont
(fontFamily="Emoji,EGA",color="#FFF",fontSizePx=16,lineHeightPx=fontSizePx,bold=false)

Set the font style to display Console buffer on the Screen.

Parameters:

fontFamily : String. "VGA", "EGA", "CGA" and "Emoji" font families supported. You might use other font families, but don't expect consistent result across all devices and browsers in this case. Specify two font families (separated by a comma) to use emojis and text. Optional parameter. If omitted equals to "Emoji,EGA".
color : String. Color value. English color name ("yellow","red") or hex format (short "#F90" or long "#FF0000") allowed. Optional parameter. If omitted equals to "#FFF".
fontSizePx : Optional parameter. If omitted equals to 16.
lineHeightPx : Optional parameter. If omitted equals to fontSizePx.
bold : Optional parameter. If omitted equals to false.



Function
setConsoleBlend
or
Console.setBlend
(blendMode="normal")

Set the Console blend mode. Experimental feature, slow on the real hardware. Following values are allowed: normal, multiply, screen, overlay, darken, lighten, color-dodge, color-burn, hard-light, soft-light, difference, exclusion, hue, saturation, color, luminosity, unset.

Parameters:

blendMode : Optional parameter. If omitted equals to "normal".



Function
showConsole
or
Console.show
(bool=true)

Show Console on the Screen.

Parameters:

bool : Boolean. Optional parameter. If omitted equals to true.



Function
hideConsole
or
Console.hide
()

Hide Console from the Screen.



Function
updateConsole
or
Console.update
()

Mark Console for a rebuild from the Console.buffer. Actual drawing will occur on the next animation frame. Call this function if direct changes were made to the Console.buffer array.





Canvas

global object and functions related to 2D drawing

Properties:

width
: Number. Width in pixels.
height
: Number. Height in pixels.
strokeStyle
: color or style to draw stokes. English color name ("yellow","red") or hex format (short "#F90" or long "#FF0000") allowed. If boolean true argument passed current Canvas.strokeStyle would be used. If boolean false argument passed - no strokes would be drawn.
fillStyle
: color or style to fill current path. English color name ("yellow","red") or hex format (short "#F90" or long "#FF0000") allowed. If boolean true argument passed current Canvas.fillStyle would be used. If boolean false argument passed - the shape won't be filled.
lineWidth
: Number. Line width in pixels.



Function
clearCanvas
or
Canvas.clear
(color="#000",width=Screen.width,height=Screen.height)

Clear the Canvas with color provided. Resets Canvas position and styles.

Parameters:

color : String. Color value. English color name ("yellow","red") or hex format (short "#F90" or long "#FF0000") allowed. Optional parameter. If omitted equals to "#000".
width : Number. Width in pixels. Optional parameter. If omitted equals to Screen.width.
height : Number. Height in pixels. Optional parameter. If omitted equals to Screen.height.



Function
setCanvasPos
or
Canvas.setPos
(x,y,z=-32768)

Parameters:

x : Number. Horizontal position in Canvas coordinates.
y : Number. Vertical position in Canvas coordinates.
z : Optional parameter. If omitted equals to -32768.



Function
setCanvasAA
or
Canvas.setAA
(antiAliasing=true)

Use this function to enable/disable Canvas anti-aliasing. Enable anti-aliasing if you need smoother-looking graphics.

Parameters:

antiAliasing : Optional parameter. If omitted equals to true.



Function
line
or
Canvas.line
(x1,y1,x2,y2,strokeStyle=true)

Stroke line from (x1,y1) to (x2,y2) with color provided (or with Canvas.strokeStyle).

Parameters:

x1 : Number. Horizontal position in Canvas coordinates of the starting point.
y1 : Number. Vertical position in Canvas coordinates of the starting point.
x2 : Number. Horizontal position in Canvas coordinates of the destination point.
y2 : Number. Vertical position in Canvas coordinates of the destination point.
strokeStyle : color or style to draw stokes. English color name ("yellow","red") or hex format (short "#F90" or long "#FF0000") allowed. If boolean true argument passed current Canvas.strokeStyle would be used. If boolean false argument passed - no strokes would be drawn. Optional parameter. If omitted equals to true.



Function
circle
or
Canvas.circle
(x,y,radius,strokeStyle=true,fillStyle=false)

Parameters:

x : Number. Horizontal position in Canvas coordinates.
y : Number. Vertical position in Canvas coordinates.
radius : Number. Defines the radius in pixels.
strokeStyle : color or style to draw stokes. English color name ("yellow","red") or hex format (short "#F90" or long "#FF0000") allowed. If boolean true argument passed current Canvas.strokeStyle would be used. If boolean false argument passed - no strokes would be drawn. Optional parameter. If omitted equals to true.
fillStyle : color or style to fill current path. English color name ("yellow","red") or hex format (short "#F90" or long "#FF0000") allowed. If boolean true argument passed current Canvas.fillStyle would be used. If boolean false argument passed - the shape won't be filled. Optional parameter. If omitted equals to false.



Function
fillCircle
or
Canvas.fillCircle
(x,y,radius,fillStyle=true)

Parameters:

x : Number. Horizontal position in Canvas coordinates.
y : Number. Vertical position in Canvas coordinates.
radius : Number. Defines the radius in pixels.
fillStyle : color or style to fill current path. English color name ("yellow","red") or hex format (short "#F90" or long "#FF0000") allowed. If boolean true argument passed current Canvas.fillStyle would be used. If boolean false argument passed - the shape won't be filled. Optional parameter. If omitted equals to true.



Function
rect
or
Canvas.rect
(x,y,width,height,strokeStyle=true,fillStyle=false)

Stroke and/or fill rectangle at (x,y) position with (width,height) dimensions.

Parameters:

x : Number. Horizontal position in Canvas coordinates.
y : Number. Vertical position in Canvas coordinates.
width : Number. Width in pixels.
height : Number. Height in pixels.
strokeStyle : color or style to draw stokes. English color name ("yellow","red") or hex format (short "#F90" or long "#FF0000") allowed. If boolean true argument passed current Canvas.strokeStyle would be used. If boolean false argument passed - no strokes would be drawn. Optional parameter. If omitted equals to true.
fillStyle : color or style to fill current path. English color name ("yellow","red") or hex format (short "#F90" or long "#FF0000") allowed. If boolean true argument passed current Canvas.fillStyle would be used. If boolean false argument passed - the shape won't be filled. Optional parameter. If omitted equals to false.



Function
fillRect
or
Canvas.fillRect
(x,y,width,height,fillStyle=true)

Parameters:

x : Number. Horizontal position in Canvas coordinates.
y : Number. Vertical position in Canvas coordinates.
width : Number. Width in pixels.
height : Number. Height in pixels.
fillStyle : color or style to fill current path. English color name ("yellow","red") or hex format (short "#F90" or long "#FF0000") allowed. If boolean true argument passed current Canvas.fillStyle would be used. If boolean false argument passed - the shape won't be filled. Optional parameter. If omitted equals to true.



Function
ellipse
or
Canvas.ellipse
(x,y,radiusX,radiusY,rotation,strokeStyle=true,fillStyle=false)

Parameters:

x : Number. Horizontal position in Canvas coordinates.
y : Number. Vertical position in Canvas coordinates.
radiusX : Number. Defines the horizontal radius in pixels.
radiusY : Number. Defines the vertical radius in pixels.
rotation : Number. Absolute rotation angle in Radians. Use degToRad() function to easily convert from Degrees to Radians.
strokeStyle : color or style to draw stokes. English color name ("yellow","red") or hex format (short "#F90" or long "#FF0000") allowed. If boolean true argument passed current Canvas.strokeStyle would be used. If boolean false argument passed - no strokes would be drawn. Optional parameter. If omitted equals to true.
fillStyle : color or style to fill current path. English color name ("yellow","red") or hex format (short "#F90" or long "#FF0000") allowed. If boolean true argument passed current Canvas.fillStyle would be used. If boolean false argument passed - the shape won't be filled. Optional parameter. If omitted equals to false.



Function
fillEllipse
or
Canvas.fillEllipse
(x,y,radiusX,radiusY,rotation,fillStyle=false)

Parameters:

x : Number. Horizontal position in Canvas coordinates.
y : Number. Vertical position in Canvas coordinates.
radiusX : Number. Defines the horizontal radius in pixels.
radiusY : Number. Defines the vertical radius in pixels.
rotation : Number. Absolute rotation angle in Radians. Use degToRad() function to easily convert from Degrees to Radians.
fillStyle : color or style to fill current path. English color name ("yellow","red") or hex format (short "#F90" or long "#FF0000") allowed. If boolean true argument passed current Canvas.fillStyle would be used. If boolean false argument passed - the shape won't be filled. Optional parameter. If omitted equals to false.



Function
arc
or
Canvas.arc
(x, y, radius, startAngle, endAngle, strokeStyle=true,fillStyle=false)

Parameters:

x : Number. Horizontal position in Canvas coordinates.
y : Number. Vertical position in Canvas coordinates.
radius : Number. Defines the radius in pixels.
startAngle : Number. Angle in Radians, counted clockwise. Use degToRad() function to easily convert from Degrees to Radians.
endAngle : Number. Angle in Radians, counted clockwise. Use degToRad() function to easily convert from Degrees to Radians.
strokeStyle : color or style to draw stokes. English color name ("yellow","red") or hex format (short "#F90" or long "#FF0000") allowed. If boolean true argument passed current Canvas.strokeStyle would be used. If boolean false argument passed - no strokes would be drawn. Optional parameter. If omitted equals to true.
fillStyle : color or style to fill current path. English color name ("yellow","red") or hex format (short "#F90" or long "#FF0000") allowed. If boolean true argument passed current Canvas.fillStyle would be used. If boolean false argument passed - the shape won't be filled. Optional parameter. If omitted equals to false.



Function
putPixel
or
Canvas.putPixel
(x,y,colorOrRGB=Canvas.fillStyle)

Put a single pixel on Canvas

Parameters:

x : Number. Horizontal position in Canvas coordinates.
y : Number. Vertical position in Canvas coordinates.
colorOrRGB : String or Array. Color value. In case if array is passed, it should contain 3 or 4 integers in range 0 to 255, representing color component values [Red, Ggreen, Blue, Alpha]. English color name ("yellow","red") or hex format (short "#F90" or long "#FF0000") allowed. Optional parameter. If omitted equals to Canvas.fillStyle.



Function
getPixel
or
Canvas.getPixel
(x,y,hexFormat=false)

Get color of a single pixel from the Canvas. By default returns an array [Red,Green,Blue,Alpha]. If hexFormat parameter provided will return color in hex format (#FFFFFF).

Parameters:

x : Number. Horizontal position in Canvas coordinates.
y : Number. Vertical position in Canvas coordinates.
hexFormat : Boolean. Pass boolean true to receive the result in hex format (like "#FFFFFF"). Optional parameter. If omitted equals to false.



Function
setStrokeStyle
or
Canvas.setStrokeStyle
(strokeStyle)

Set the Canvas.strokeStyle property. This style would be applied to all consecutive stroke operations.

Parameters:

strokeStyle : color or style to draw stokes. English color name ("yellow","red") or hex format (short "#F90" or long "#FF0000") allowed. If boolean true argument passed current Canvas.strokeStyle would be used. If boolean false argument passed - no strokes would be drawn.



Function
setFillStyle
or
Canvas.setFillStyle
(fillStyle)

Set the Canvas.fillStyle property. This style would be applied to all consecutive fill operations.

Parameters:

fillStyle : color or style to fill current path. English color name ("yellow","red") or hex format (short "#F90" or long "#FF0000") allowed. If boolean true argument passed current Canvas.fillStyle would be used. If boolean false argument passed - the shape won't be filled.



Function
setLineWidth
or
Canvas.setLineWidth
(lineWidth=1)

Set Canvas.lineWidth property, changing the line width for all consecutive line drawing operations.

Parameters:

lineWidth : Number. Line width in pixels. Optional parameter. If omitted equals to 1.



Function
showCanvas
or
Canvas.show
(bool=true)

Show Canvas on the Screen.

Parameters:

bool : Boolean. Optional parameter. If omitted equals to true.



Function
hideCanvas
or
Canvas.hide
()

Hide Canvas from the Screen.



Function
setCanvasFont
or
Canvas.setFont
(fontFamily="Emoji,EGA",color="#FFF",fontSizePx=16,bold=false)

Set the font parameters to draw text with the following Canvas.fillText or Canvas.strokeText functions. Alters Canvas.fillStyle and Canvas.strokeStyle.

Parameters:

fontFamily : String. "VGA", "EGA", "CGA" and "Emoji" font families supported. You might use other font families, but don't expect consistent result across all devices and browsers in this case. Specify two font families (separated by a comma) to use emojis and text. Optional parameter. If omitted equals to "Emoji,EGA".
color : String. Color value. English color name ("yellow","red") or hex format (short "#F90" or long "#FF0000") allowed. Optional parameter. If omitted equals to "#FFF".
fontSizePx : Optional parameter. If omitted equals to 16.
bold : Optional parameter. If omitted equals to false.



Function
fillText
or
Canvas.fillText
(text, x, y, maxWidth)

Parameters:

text : String.
x : Number. Horizontal position in Canvas coordinates.
y : Number. Vertical position in Canvas coordinates.
maxWidth : Number. Optional parameter. The maximum number of pixels wide the text should be when rendered.



Function
strokeText
or
Canvas.strokeText
(text, x, y, maxWidth)

Parameters:

text : String.
x : Number. Horizontal position in Canvas coordinates.
y : Number. Vertical position in Canvas coordinates.
maxWidth : Number. Optional parameter. The maximum number of pixels wide the text should be when rendered.



Function
measureText
or
Canvas.measureText
(text)

Measure provided text, using current font metrics.

Parameters:

text : String.

Returns:

TextMetrics object that contains following properties: width, actualBoundingBoxLeft, actualBoundingBoxRight, fontBoundingBoxAscent, fontBoundingBoxDescent, actualBoundingBoxAscent, actualBoundingBoxDescent, emHeightAscent, emHeightDescent, hangingBaseline, alphabeticBaseline, ideographicBaseline.



Function
beginPath
or
Canvas.beginPath
()

Starts a new sub-path.



Function
closePath
or
Canvas.closePath
()

Closes the current sub-path, drawing straight line to the start of the path. Call Canvas.fill() or Canvas.stroke() later to fill or stroke the current path.



Function
moveTo
or
Canvas.moveTo
(x, y)

Move the starting point of a new sub-path to (x, y)

Parameters:

x : Number. Horizontal position in Canvas coordinates.
y : Number. Vertical position in Canvas coordinates.



Function
lineTo
or
Canvas.lineTo
(x, y)

Connect the current pen position and (x, y) with the straight line in current sub-path. Call Canvas.stroke() later to stroke the current path.

Parameters:

x : Number. Horizontal position in Canvas coordinates.
y : Number. Vertical position in Canvas coordinates.



Function
bezierCurveTo
or
Canvas.bezierCurveTo
(cpx, cpy, cp2x, cp2y, epx, epy)

Parameters:

cpx : Number. Horizontal position in Canvas coordinates of the control point.
cpy : Number. Vertical position in Canvas coordinates of the control point.
cp2x : Number. Horizontal position in Canvas coordinates of the second control point.
cp2y : Number. Vertical position in Canvas coordinates of the second control point.
epx : Number. Horizontal position in Canvas coordinates of the end point.
epy : Number. Vertical position in Canvas coordinates of the end point.



Function
quadraticCurveTo
or
Canvas.quadraticCurveTo
(cpx, cpy, epx, epy)

Parameters:

cpx : Number. Horizontal position in Canvas coordinates of the control point.
cpy : Number. Vertical position in Canvas coordinates of the control point.
epx : Number. Horizontal position in Canvas coordinates of the end point.
epy : Number. Vertical position in Canvas coordinates of the end point.



Function
arcTo
or
Canvas.arcTo
(x1, y1, x2, y2, radius)

Parameters:

x1 : Number. Horizontal position in Canvas coordinates of the starting point.
y1 : Number. Vertical position in Canvas coordinates of the starting point.
x2 : Number. Horizontal position in Canvas coordinates of the destination point.
y2 : Number. Vertical position in Canvas coordinates of the destination point.
radius : Number. Defines the radius in pixels.



Function
fill
or
Canvas.fill
()

Fill the current sub-path with Canvas.fillStyle



Function
stroke
or
Canvas.stroke
()

Stroke the current sub-path with Canvas.strokeStyle



Function
putImageData
or
Canvas.putImageData
(imageData, dx, dy, rx=0, ry=0, width=imageData.width, height=imageData.height)

Parameters:

imageData : ImageData object. Contains following properties: data (one-dimensional array containing the pixel data in the RGBA order), height (height of the area), width (width of the area)
dx : Number. Horizontal position in Canvas coordinates to draw the image.
dy : Number. Vertical position in Canvas coordinates to draw the image.
rx : Number. Horizontal coordinate of the sub-rectangle of the source image. Optional parameter. If omitted equals to 0.
ry : Number. Vertical coordinate of the sub-rectangle of the source image. Optional parameter. If omitted equals to 0.
width : Number. Width in pixels. Optional parameter. If omitted equals to imageData.width.
height : Number. Height in pixels. Optional parameter. If omitted equals to imageData.height.

Example:




Function
getImageData
or
Canvas.getImageData
(rx, ry, width, height)

Parameters:

rx : Number. Horizontal coordinate of the sub-rectangle of the source image.
ry : Number. Vertical coordinate of the sub-rectangle of the source image.
width : Number. Width in pixels.
height : Number. Height in pixels.

Returns:

ImageData object. Contains following properties: data (one-dimensional array containing the pixel data in the RGBA order), height (height of the area), width (width of the area)

Example:




Function
drawImage
or
Canvas.drawImage
(image, dx, dy)

Draw Image on Canvas. Make sure image is loaded and ready before drawing.

Parameters:

image : Object. Could be Sprite or HTMLImageElement object.
dx : Number. Horizontal position in Canvas coordinates to draw the image.
dy : Number. Vertical position in Canvas coordinates to draw the image.



Function
drawImage
or
Canvas.drawImage
(image, dx, dy, dWidth, dHeight)

Draw Image on Canvas. Make sure image is loaded and ready before drawing.

Parameters:

image : Object. Could be Sprite or HTMLImageElement object.
dx : Number. Horizontal position in Canvas coordinates to draw the image.
dy : Number. Vertical position in Canvas coordinates to draw the image.
dWidth : Number. Width of the image rectangle on Canvas.
dHeight : Number. Height of the image rectangle on Canvas.



Function
drawImage
or
Canvas.drawImage
(image, rx, ry, rWidth, rHeight, dx, dy, dWidth, dHeight)

Draw Image on Canvas. Make sure image is loaded and ready before drawing.

Parameters:

image : Object. Could be Sprite or HTMLImageElement object.
rx : Number. Horizontal coordinate of the sub-rectangle of the source image.
ry : Number. Vertical coordinate of the sub-rectangle of the source image.
rWidth : Number. Width of the sub-rectangle of the source image.
rHeight : Number. Height of the sub-rectangle of the source image.
dx : Number. Horizontal position in Canvas coordinates to draw the image.
dy : Number. Vertical position in Canvas coordinates to draw the image.
dWidth : Number. Width of the image rectangle on Canvas.
dHeight : Number. Height of the image rectangle on Canvas.



Function
linearGradient
or
Canvas.linearGradient
(x1, y1, x2, y2)

Parameters:

x1 : Number. Horizontal position in Canvas coordinates of the starting point.
y1 : Number. Vertical position in Canvas coordinates of the starting point.
x2 : Number. Horizontal position in Canvas coordinates of the destination point.
y2 : Number. Vertical position in Canvas coordinates of the destination point.



Function
radialGradient
or
Canvas.radialGradient
(x1, y1, r1, x2, y2, r2)

Parameters:

x1 : Number. Horizontal position in Canvas coordinates of the starting point.
y1 : Number. Vertical position in Canvas coordinates of the starting point.
r1 : Number. Defines the radius in pixels.
x2 : Number. Horizontal position in Canvas coordinates of the destination point.
y2 : Number. Vertical position in Canvas coordinates of the destination point.
r2 : Number. Defines the radius in pixels.





Audio

global object and functions related to sound and music



Function
say
or
Audio.say
(text,lang="en-US")

Add a sentence to the text-to-speech buffer queue.

Parameters:

text : String.
lang : Language constant:
"de-DE" - German
"en-GB" - United Kingdom English
"en-US" - United States English (default)
"es-ES" - Spanish
"fr-FR" - French
"it-IT" - Italian
"ru-RU" - Russian (Cyrillic characters not supported yet - use translit).
Optional parameter. If omitted equals to "en-US".



Function
sayOut
or
Audio.sayOut
(text,lang="en-US")

Clear text-to-speech buffer and say the sentence at once.

Parameters:

text : String.
lang : Language constant:
"de-DE" - German
"en-GB" - United Kingdom English
"en-US" - United States English (default)
"es-ES" - Spanish
"fr-FR" - French
"it-IT" - Italian
"ru-RU" - Russian (Cyrillic characters not supported yet - use translit).
Optional parameter. If omitted equals to "en-US".



Function
setVolume
or
Audio.setVolume
(volume,channel=0)

Set volume for the audio channel specified.

Parameters:

volume : Number. Should be in range 0.00 to 1.00
channel : Audio channel number. Optional parameter. If omitted equals to 0.



Function
setOscillator
or
Audio.setOscillator
(oscillatorType,channel=0)

Set the oscillator type for the audio channel specified. Clears the channel.

Parameters:

oscillatorType : String. Supported types are: "sine","square","sawtooth","triangle".
channel : Audio channel number. Optional parameter. If omitted equals to 0.



Function
clearAudio
or
Audio.clear
(channel=0)

Clear the audio channel play queue. Stops sound generation.

Parameters:

channel : Audio channel number. Optional parameter. If omitted equals to 0.



Function
sound
or
Audio.sound
(frequency,duration,fade=0,channel=0)

Adds sound with specified frequency to the audio channel play queue.

Parameters:

frequency : Number. Frequency of the sound in Hz.
duration : Number. Duration of the sound in Seconds.
fade : Number. Specifies how much sound should fade through the duration in range 0.00 to 1.00 Optional parameter. If omitted equals to 0.
channel : Audio channel number. Optional parameter. If omitted equals to 0.



Function
playMidiNote
or
Audio.playMidiNote
(note,duration,fade=0,channel=0)

Adds the frequency corresponding to the MIDI note number to the audio channel play queue.

Parameters:

note : Number. Note number as per MIDI specification in range 0 to 127
duration : Number. Duration of the sound in Seconds.
fade : Number. Specifies how much sound should fade through the duration in range 0.00 to 1.00 Optional parameter. If omitted equals to 0.
channel : Audio channel number. Optional parameter. If omitted equals to 0.



Function
beep
or
Audio.beep
(pitch,duration,channel=0)

Add simple beep sound to the audio channel play queue. Command is similar to the one found in ZX Spectrum Basic. Be aware that argument order differs. ZX Basic BEEP 1,0 equals to Tauon Basic Script beep(0,1).

Parameters:

pitch : Number. Pitch of the sound, given in semitones above middle C. Use negative numbers for notes below middle C.
duration : Number. Duration of the sound in Seconds.
channel : Audio channel number. Optional parameter. If omitted equals to 0.



Function
playMusic
or
Audio.playMusic
(musicNotationString,channel=0)

Parse music notation string and add resulting frequencies to the audio channel play queue.

Parameters:

musicNotationString : The notation might start with BPM character sequence, for example, "BPM120"
This defines the Tempo of the music. The default Tempo is 120.
You can set the current Octave with the O character, followed by the octave number (0-9). For example "O3" sets the third octave as a default one for the notes that will follow. The default octave is 4.
Capital letters represent single Note: C, D, E, F, G, A, B.
R character represents Rest (pause). It is treated as a Note by the engine, so all duration modifications could be applied.
# (sharp) symbol before Note raises the Note by a semitone (half-step up), for example, sharp C could be written as "#C".
b (small B letter) before Note lowers the Note by a semitone (half-step down), for example, flat D could be written as "bD".
To modify the octave of the Note - add a single number just after the Note: "C5" equals C from the fifth octave. "C+" will shift the octave up and "C-" - down. This octave shift doesn't affect the notes that will follow.
You can control the duration of notes that will follow using the L modifier. With L0 being the longest (Semibreve) and L6 being shortest (Hemidemisemiquaver).
The multiply character "*" after the Note will increase its duration by the factor of two. Two characters will increase Note duration by the factor of four.
The slash character "/" after the Note will decrease its duration by half. Two slashes will decrease Note duration by the factor of four.
The dot "." character after the Note increases duration by half. Two dots ".." will increase the duration by 1/2+1/4 and so on.
Underscore "_" character specifies that the current note is beamed with the following one.

channel : Audio channel number. Optional parameter. If omitted equals to 0.



Function
getAudioQueue
or
Audio.getQueue
(channel=0)

Get the remaining play queue length (in seconds) for the audio channel specified.

Parameters:

channel : Audio channel number. Optional parameter. If omitted equals to 0.





Sprite

object properties and functions related to Sprite manipulation

Properties:

px
: Number. Horizontal position coordinate.
py
: Number. Vertical position coordinate.
pz
: Number. Z-index of the object. An element with greater z-index is always in front of an element with a lower z-index.
sx
: Number. Absolute horizontal Sprite scale factor.
sy
: Number. Absolute vertical Sprite scale factor.
r
: Number. Absolute rotation in Radians. Use radToDeg() function to easily convert from Radians to Degrees



Function
spriteFromEmoji
or
Sprite.fromEmoji
(emoji,size=16,paperColor='')

Create Sprite from one or more Emoji characters.

Parameters:

emoji : String. One or more emoji character. Emoji font would be used to draw glyphs.
size : Number. Font size (in pixels) to draw characters with. Optional parameter. If omitted equals to 16.
paperColor : String. Background color for the Sprite. English color name ("yellow","red") or hex format (short "#F90" or long "#FF0000") allowed. Optional parameter. If omitted equals to ''.

Returns:

Reference to the newly created Sprite object. It might take some time for Sprite to load and initialize. Use Sprite.isReady and Sprite.whenReady functions if you wish to clone the Sprite or draw it on Canvas.



Function
spriteFromText
or
Sprite.fromText
(text,fontFamily="EGA",size=16,inkColor="#FFFFFFFF",paperColor="transparent")

Create Sprite from one or more characters.

Parameters:

text : String.
fontFamily : String. "VGA", "EGA", "CGA" and "Emoji" font families supported. You might use other font families, but don't expect consistent result across all devices and browsers in this case. Specify two font families (separated by a comma) to use emojis and text. Optional parameter. If omitted equals to "EGA".
size : Number. Font size (in pixels) to draw characters with. Optional parameter. If omitted equals to 16.
inkColor : String. Color to draw character with. English color name ("yellow","red") or hex format (short "#F90" or long "#FF0000") allowed. Optional parameter. If omitted equals to "#FFFFFFFF".
paperColor : String. Background color for the Sprite. English color name ("yellow","red") or hex format (short "#F90" or long "#FF0000") allowed. Optional parameter. If omitted equals to "transparent".

Returns:

Reference to the newly created Sprite object. It might take some time for Sprite to load and initialize. Use Sprite.isReady and Sprite.whenReady functions if you wish to clone the Sprite or draw it on Canvas.



Function
spriteFromData
or
Sprite.fromData
(pixelData,width,height,paletteIndex=0)

Create Sprite from image data string. Each character represents index in palette [0..9A..Z] and defines color of the single pixel. The two default palettes have 17 colors [0..G]. You can use ' ' space character in the string to draw transparent pixel.

Palette 0:  0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F  G 

Palette 1:  0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F  G 

Parameters:

pixelData : String. Each character represents index in palette [0..9A..Z] and defines color of the single pixel. The two default palettes have 17 colors [0..G]. You can create more palettes with setPalette function.
width : Number. Width in pixels.
height : Number. Height in pixels.
paletteIndex : Number. Palette index to use. By default Tauon Basic Script has two palettes with indexes 0 and 1. You can create new or modify existing palette with setPalette function. Optional parameter. If omitted equals to 0.

Returns:

Reference to the newly created Sprite object. It might take some time for Sprite to load and initialize. Use Sprite.isReady and Sprite.whenReady functions if you wish to clone the Sprite or draw it on Canvas.



Function
spriteFromBin
or
Sprite.fromBin
(bytesArray,width,height,inkColor="#FFFFFFFF",paperColor="#00000000")

Create Sprite from binary data array. Each element of the array would be treated as a binary number [0..255]. Each bit of that number will define 8 pixels of the Sprite. All bits equal to 1 would produce pixels with inkColor. Bits equal to 0 - with paperColor. If paperColor parameter is omitted, a transparent color would be used.

Parameters:

bytesArray : Array of bytes in range 0 to 255. Each element of the array will define 8 pixels of the Sprite.
width : Number. Width in pixels.
height : Number. Height in pixels.
inkColor : String. Color to draw character with. English color name ("yellow","red") or hex format (short "#F90" or long "#FF0000") allowed. Optional parameter. If omitted equals to "#FFFFFFFF".
paperColor : String. Background color for the Sprite. English color name ("yellow","red") or hex format (short "#F90" or long "#FF0000") allowed. Optional parameter. If omitted equals to "#00000000".

Returns:

Reference to the newly created Sprite object. It might take some time for Sprite to load and initialize. Use Sprite.isReady and Sprite.whenReady functions if you wish to clone the Sprite or draw it on Canvas.

Example:




Function
spriteFromUrl
or
Sprite.fromUrl
(url)

Parameters:

url : String. Uniform Resource Locator. Could point to external address to load image from the web or could contain in-line data.

Example:




Function
spriteFromFile
or
Sprite.fromFile
(fileName)

Parameters:

fileName : String. File name. Could contain relative or absolute file system path.

Example:




Function
spriteGroup
or
Sprite.group
(...)

Create new SpriteGroup object and add it to the Screen. Pass various Sprites as parameters to add them to the group. You can add more Sprites later using spriteGroup.appendChild function.

Parameters:

any number of parameters, separated by coma.



Function
showSprite
or
Sprite.show
(sprite,bool=true)

Parameters:

sprite : previously created or loaded Sprite object.
bool : Boolean. Optional parameter. If omitted equals to true.



Function
hideSprite
or
Sprite.hide
(sprite)

Parameters:

sprite : previously created or loaded Sprite object.



Function
setSprite
or
Sprite.set
(sprite,px,py,pz,rotation,scaleX,scaleY)

Parameters:

sprite : previously created or loaded Sprite object.
px : Number. Horizontal position coordinate.
py : Number. Vertical position coordinate.
pz : Number. Z-index of the object. An element with greater z-index is always in front of an element with a lower z-index.
rotation : Number. Absolute rotation angle in Radians. Use degToRad() function to easily convert from Degrees to Radians.
scaleX : Number. Absolute horizontal Sprite scale factor.
scaleY : Number. Absolute vertical Sprite scale factor.



Function
setSpritePos
or
Sprite.setPos
(sprite,px,py,pz)

Set the Sprite position.

Parameters:

sprite : previously created or loaded Sprite object.
px : Number. Horizontal position coordinate.
py : Number. Vertical position coordinate.
pz : Number. Z-index of the object. An element with greater z-index is always in front of an element with a lower z-index.



Function
setSpriteRot
or
Sprite.setRot
(sprite,rotation)

Set Sprite rotation around its pivot point in Radians.

Parameters:

sprite : previously created or loaded Sprite object.
rotation : Number. Absolute rotation angle in Radians. Use degToRad() function to easily convert from Degrees to Radians.

Example:




Function
setSpriteScale
or
Sprite.setScale
(sprite,scaleX,scaleY=scaleX)

Parameters:

sprite : previously created or loaded Sprite object.
scaleX : Number. Absolute horizontal Sprite scale factor.
scaleY : Number. Absolute vertical Sprite scale factor. Optional parameter. If omitted equals to scaleX.



Function
setSpritePivot
or
Sprite.setPivot
(sprite,pivotX,pivotY)

Set Sprite pivot point. The pivot defines the starting point for all transforms.

Parameters:

sprite : previously created or loaded Sprite object.
pivotX : Number. Horizontal position coordinate.
pivotY : Number. Vertical position coordinate.



Function
setSpriteOpacity
or
Sprite.setOpacity
(sprite,opacity=1.0)

Parameters:

sprite : previously created or loaded Sprite object.
opacity : Number. Should be in range 0.00 to 1.00 Optional parameter. If omitted equals to 1.0.

Example:




Function
setSpriteFilter
or
Sprite.setFilter
(sprite,filter="none")

Apply CSS filter to the Sprite. You can stack filters separating them with space character.

Parameters:

sprite : previously created or loaded Sprite object.
filter : String. Supported filters are: none, blur(), brightness(), contrast(), drop-shadow(), grayscale(), hue-rotate(), invert(), opacity(), saturate(), sepia() Optional parameter. If omitted equals to "none".

Example:




Function
isSpriteReady
or
Sprite.isReady
(sprite)

Returns true if Sprite is loaded and fully initialized.

Parameters:

sprite : previously created or loaded Sprite object.



Function
whenSpriteReady
or
Sprite.whenReady
(sprite,callback)

Calls callback function when Sprite is loaded and fully initialized.

Parameters:

sprite : previously created or loaded Sprite object.
callback : Function reference. Function to call when operation is completed.



Function
cloneSprite
or
Sprite.clone
(sprite)

Returns cloned Sprite or SpriteGroup. Make sure the source Sprite is ready or function will throw an error.

Parameters:

sprite : previously created or loaded Sprite object.

Returns:

Reference to the newly created Sprite object. It might take some time for Sprite to load and initialize. Use Sprite.isReady and Sprite.whenReady functions if you wish to clone the Sprite or draw it on Canvas.



Function
destroySprite
or
Sprite.destroy
(sprite)

Detach Sprite from the Screen and free all resources associated with the Sprite object.

Parameters:

sprite : previously created or loaded Sprite object.

Returns:

null

Example:






Time

global object containing information related to time and frames

Properties:

time
: Number. Time since the current program is started in seconds.
dt
: Number. Time passed since the last frame drawn, in seconds.
sdt
: Number. The smoothed average time between drawing frames, in seconds.
now
: Number. Current system time in milliseconds.
fps
: Number. Average FPS.
tick
: Number. The number of frames drawn since the program started.





Math

global object and functions related to mathematics

Properties:

E
: Euler's constant and the base of natural logarithms (approximately 2.71828)
PI
: The ratio of a circle's circumference to its diameter (approximately 3.14159)
LN2
: Natural logarithm of 2 (approximately 0.69314)
LN10
: Natural logarithm of 10 (approximately 2.30259)
LOG2E
: Base-2 logarithm of E (approximately 1.44270)
LOG10E
: Base-10 logarithm of E (approximately 0.43429)



Function
abs
or
Math.abs
(X)

Returns the absolute value of X



Function
atan
or
Math.atan
(X)

Returns the arctangent of X



Function
cos
or
Math.cos
(X)

Returns the cosine of X



Function
exp
or
Math.exp
(X)

Returns E raised to power of X, where X is the argument, and E is Euler's constant



Function
int
or
Math.trunc
(X)

Returns the integer portion of X



Function
log
or
Math.log
(X)

Returns the natural logarithm of X



Function
pow
or
Math.pow
(X,Y)

Returns base X to the exponent power of Y



Function
rnd
or
random
or
Math.random
()

Returns a pseudo-random number in range 0 to 1



Function
sin
or
Math.sin
(X)

Returns the sine of X



Function
sqrt
or
Math.sqrt
(X)

Returns the positive square root of X



Function
tan
or
Math.tan
(X)

Returns the tangent of X



Function
round
or
Math.round
(X)

Returns X rounded to the nearest integer



Function
ceil
or
Math.ceil
(X)

Returns X rounded up to the next largest integer.



Function
floor
or
Math.floor
(X)

Returns the largest integer less than or equal to X



Function
clamp
or
Math.clamp
(X,lower,upper)

Returns the value of X, clamped between an upper and lower bound.



Function
max
or
Math.max
(...)

Returns the largest argument.

Parameters:

any number of parameters, separated by coma.



Function
min
or
Math.min
(...)

Returns the smallest argument.

Parameters:

any number of parameters, separated by coma.



Function
degToRad
or
Math.degToRad
(degrees)

Parameters:

degrees : Number. Angle in Degrees units.

Returns:

Number. Angle in Radians units.

Example:




Function
radToDeg
or
Math.radToDeg
(radians)

Parameters:

radians : Number. Angle in Radians units.

Returns:

Number. Angle in Degrees units.





File

global object and functions to access the filesystem

Properties:

currentDir
: String. File system path to the current working directory.



Function
readFile
or
File.read
(fileName,callback)

Asynchronously read the file and pass its content to the callback function as String parameter.

Parameters:

fileName : String. File name. Could contain relative or absolute file system path.
callback : Function reference. Function to call when operation is completed.



Function
writeFile
or
File.write
(fileName,content,callback)

Asynchronously write content to the file and call the callback function when done.

Parameters:

fileName : String. File name. Could contain relative or absolute file system path.
content : String. Content to write into the file.
callback : Function reference. Function to call when operation is completed.



Function
listFiles
or
File.list
(path,callback)

Asynchronously read the directory and pass its content to the callback function as array.

Parameters:

path : String. File system path. Could be relative or absolute file system path.
callback : Function reference. Function to call when operation is completed.



Function
removeFile
or
File.remove
(fileName,callback)

Parameters:

fileName : String. File name. Could contain relative or absolute file system path.
callback : Function reference. Function to call when operation is completed.



Function
makeDir
or
File.makeDir
(fileName,callback)

Parameters:

fileName : String. File name. Could contain relative or absolute file system path.
callback : Function reference. Function to call when operation is completed.





Array

object stores a collection of items under a single variable name, and has built-in functions to perform common array operations.

Properties:

length
: returns the current length.
[]
: are used to access stored elements by index.

Example:






String

object is used to represent sequence of characters, and has built-in functions to perform common operations.

Properties:

length
: returns the current length.
[]
: are used to access stored elements by index.

Example:






Built-in functions



Function
len
(obj)

Returns the length of an Array or String object. If obj is of type Set or Map - will return it size.

Parameters:

obj : Object.



Function
alert
(text)

Show an alert box with a specified text and an OK button.

Parameters:

text : String.



Function
confirm
(text)

Show a dialog box with OK and Cancel buttons. Returns true if "OK" button pressed, false otherwise.

Parameters:

text : String.

Returns:

Boolean.



Function
prompt
(text, default)

Show a dialog box with a specified text, an input field, and an OK button. Returns a user-inputted string.

Parameters:

text : String.
default : String. The default value.

Returns:

String.



Function
parseInt
(str, radix)

Return the integer value parsed from the argument string.

Parameters:

str : String.
radix : Number. Optional parameter. An integer between 2 and 36 that represents the base of the numeral system.

Returns:

Number.

Example:




Function
parseFloat
(str)

Return the float value parsed from the argument string.

Parameters:

str : String.

Returns:

Number.



Function
isNaN
(value)

Returns true if value is NaN (Not-a-Number).

Parameters:

value : String. Console buffer representation as String. Would be re-built from buffer on the next frame if set to null.



Function
setInterval
(function, milliseconds)

This method calls a function repeatedly after a number of milliseconds.

Parameters:

function : Function reference.
milliseconds : Number. Delay in milliseconds.

Returns:

Number. Could be used to prevent function execution using clearInterval(intervalId).



Function
clearInterval
(intervalId)

Prevent function execution set with setInterval.

Parameters:

intervalId : Number. Could be used to prevent function execution using clearInterval(intervalId).



Function
setTimeout
(function, milliseconds)

This method calls a function after a number of milliseconds.

Parameters:

function : Function reference.
milliseconds : Number. Delay in milliseconds.

Returns:

Number. Could be used to prevent function execution using clearTimeout(timeoutId).



Function
clearTimeout
(timeoutId)

Prevent function execution set with setTimeout.

Parameters:

timeoutId : Number. Could be used to prevent function execution using clearTimeout(timeoutId).



Function
split
(str='',separator='',limit)

Splits the string into an array of substrings, using separator as delimeter pattern.

Parameters:

str : String. Optional parameter. If omitted equals to ''.
separator : Optional parameter. If omitted equals to ''.
limit : Number. Optional parameter. Limits function output to first N elements.



Function
splitUnicode
(str='')

Splits the string into an array of characters, preserving Unicode codepoints. Useful when working with strings containing Emojis.

Parameters:

str : String. Optional parameter. If omitted equals to ''.

Returns:

Array.

Example:




Function
addSlashes
(str)

Escape the string to safely pass it to the Linux shell command.

Parameters:

str : String.

Returns:

String.



Function
getMouseX
()

Returns mouse horizontal postion on the screen.



Function
getMouseY
()

Returns mouse vertical postion on the screen.



Function
isMouseDown
(btnCode)

Returns true if mouse button is currently down.

Parameters:

btnCode : Number. 0 - left mouse button. 2 - right mouse button.

Returns:

Boolean.



Function
isKeyDown
(keyCode)

Returns true if keyboard key with specified scan code is pressed.

Parameters:

keyCode : Number. Keyboard key code. Some useful codes are:
[1] key - 49, [A] key - 65, [Enter] - 13, [Space] - 32, [F1] key - 112.

Returns:

Boolean.



Function
setPalette
(paletteIndex,colorArray=[])

Parameters:

paletteIndex : Number. Palette index to use. By default Tauon Basic Script has two palettes with indexes 0 and 1. You can create new or modify existing palette with setPalette function.
colorArray : Array. Each element of the array should be a string containing valid color. Both English color names ("yellow","red") and hex format (short "#F90" or long "#FF0000") forms are supported. Optional parameter. If omitted equals to [].



Function
rgbaToColor
(rgba=[255,255,255,255])

Parameters:

rgba : Array. Should contain 3 or 4 integers in range 0 to 255, representing color component values [Red, Ggreen, Blue, Alpha]. Optional parameter. If omitted equals to [255,255,255,255].

Returns:

String. Color value. English color name ("yellow","red") or hex format (short "#F90" or long "#FF0000") allowed.



Function
colorToRGBA
(color)

Parameters:

color : String. Color value. English color name ("yellow","red") or hex format (short "#F90" or long "#FF0000") allowed.

Returns:

Array. Should contain 3 or 4 integers in range 0 to 255, representing color component values [Red, Ggreen, Blue, Alpha].



Function
palToHex
or
paletteCharToHexColor
(colorIndex,paletteIndex=0)

Get color corresponding to the colorIndex index from the paletteIndex palette.

Parameters:

colorIndex : String. or Number. Color index in the Palette. Supported indexes are from "0" to "9" and from "A" to "Z". If argument of Number type provided it would be treated as numeical color index.
paletteIndex : Number. Palette index to use. By default Tauon Basic Script has two palettes with indexes 0 and 1. You can create new or modify existing palette with setPalette function. Optional parameter. If omitted equals to 0.

Returns:

String. Color value. English color name ("yellow","red") or hex format (short "#F90" or long "#FF0000") allowed.



Function
endOnAnyKey
(bool=true)

Call this function with argument false to prevent program termination on any keypress.

Parameters:

bool : Boolean. Optional parameter. If omitted equals to true.



Function
shellExec
(cmd,callback)

Execute Linux shell command and pass the result to the callback function when done.

Parameters:

cmd : String. Linux shell command to execute.
callback : Function reference. Function to call when operation is completed.



Function
debug
(...)

Adds debug text message to the IDE console

Parameters:

any number of parameters, separated by coma.



Function
warn
(...)

Adds warning mesasge to the IDE console

Parameters:

any number of parameters, separated by coma.



Function
error
(...)

Adds an error description to the IDE console and terminates the program execution

Parameters:

any number of parameters, separated by coma.



Function
end
()

Return to IDE or exit from the application if in standalone mode.





Built-in event handlers

Define following functions in the code to handle events.



Function
onUpdate
()

If defined, engine will call this function on each frame.

Example:




Function
onInput
(text)

If defined, this function would be called when the user gives a response to the input statement.

Parameters:

text : String.

Example:




Function
onKeyDown
(key,keyCode,keyEvent)

Parameters:

key : String. Keyboard key name in the upper case. For example: "A", "SPACE", "SHIFT", "ARROWLEFT", etc.
keyCode : Number. Keyboard key code. Some useful codes are:
[1] key - 49, [A] key - 65, [Enter] - 13, [Space] - 32, [F1] key - 112.
keyEvent : KeyboardEvent. Keyboard event object. Contains following read-only fields: code, key, repeat, altKey, ctrlKey, shiftKey, metaKey.

Example:




Function
onKeyPress
(key,keyCode,keyEvent)

Parameters:

key : String. Keyboard key name in the upper case. For example: "A", "SPACE", "SHIFT", "ARROWLEFT", etc.
keyCode : Number. Keyboard key code. Some useful codes are:
[1] key - 49, [A] key - 65, [Enter] - 13, [Space] - 32, [F1] key - 112.
keyEvent : KeyboardEvent. Keyboard event object. Contains following read-only fields: code, key, repeat, altKey, ctrlKey, shiftKey, metaKey.



Function
onKeyUp
(key,keyCode,keyEvent)

Parameters:

key : String. Keyboard key name in the upper case. For example: "A", "SPACE", "SHIFT", "ARROWLEFT", etc.
keyCode : Number. Keyboard key code. Some useful codes are:
[1] key - 49, [A] key - 65, [Enter] - 13, [Space] - 32, [F1] key - 112.
keyEvent : KeyboardEvent. Keyboard event object. Contains following read-only fields: code, key, repeat, altKey, ctrlKey, shiftKey, metaKey.



Function
onMouseDown
(btnCode,mouseEvent)

Parameters:

btnCode : Number. 0 - left mouse button. 2 - right mouse button.
mouseEvent : MouseEvent. Mouse event object. Contains following read-only fields: button, buttons, detail, altKey, ctrlKey, shiftKey, metaKey.



Function
onMouseUp
(btnCode,mouseEvent)

Parameters:

btnCode : Number. 0 - left mouse button. 2 - right mouse button.
mouseEvent : MouseEvent. Mouse event object. Contains following read-only fields: button, buttons, detail, altKey, ctrlKey, shiftKey, metaKey.



Function
onMouseMove
(mouseX,mouseY,mouseEvent)

Parameters:

mouseX : Number. Horizontal position in screen coordinates of the Mouse cursor.
mouseY : Number. Vertical position in screen coordinates of the Mouse cursor.
mouseEvent : MouseEvent. Mouse event object. Contains following read-only fields: button, buttons, detail, altKey, ctrlKey, shiftKey, metaKey.

Example: