Gear Works
gearWorks
Used for handling system occurances and insctructions.
gearWorks.log(str)
Logs a string in the console.
gearWorks.warn(str)
Logs a warning string in the console.
gearWorks.error(str)
Logs a error in the console.
gearWorks.url(name)
Returns a conversion of a project file to a data url.
gearWorks.playSound(name)
Plays a sound found in the project files.
input
Used to determine what the user is doing at any given moment.
mouse.x
Returns mouse x.
mouse.y
Returns mouse y.
keyboard
Returns an array of all keys being pressed at any given moment.
keyboard[keyboard.length-1]
Returns the last key pressed.
keyboard.includes(key)
Checks if a key is being pressed.
draw
Used for drawing things on the canvas.
draw.background(cssColor)
Clears the screen and displays a solid color. Example:
draw.background("darkrgb(80, 80, 245);");
draw.fillRect(x, y, width, height)
Draws a "filled" rectange.
draw.strokeRect(x, y, width, height)
Draws a rectangle (with no fill).
draw.clearRect(x, y, width, height)
Clears specified pixels within a rectangle.
draw.image(name, x, y, width, height)
Draws an image from the cabinet on the canvas.
draw.beginPath()
Begins a new path or resets the current path.
draw.closePath()
Adds a line to the path from the current point to the start.
draw.moveTo(x, y)
Moves the path to a point in the canvas (without drawing).
draw.lineTo(x, y)
Adds a line to the path.
draw.fill()
Fills the current path.
draw.stroke()
Draws the current path.
draw.arc(x, y, r, startAngle, endAngle)
Adds an arc/curve (circle, or parts of a circle) to the path.
draw.fillText(text, x, y)
Draws "filled" text on the canvas.
draw.strokeText(text, x, y)
Draws text (with no fill).
draw.font = cssFont
Sets or returns the font properties for text content. Example:
draw.font = "50px Arial";
draw.textAlign = cssAlign
Sets or returns the alignment for text content. Example:
draw.textAlign = "center";
draw.lineWidth = width
Sets or returns the width of 'stroked' lines.
draw.fillStyle = cssColor
Sets or returns the color, gradient, or pattern used to fill the drawing.
draw.strokeStyle = cssColor
Sets or returns the color, gradient, or pattern used for strokes.
JavaScript
Operators
Used in everyday programming, these are very important to know.
+
Addition symbol.
-
Subtraction symbol.
*
Multiplication symbol.
/
Division symbol.
%
Modulus symbol.
||
Or symbol.
&&
And symbol.
!
Not symbol.
!=
Not equal to symbol.
==
Equal to symbol (Not to be confused with a single =, that is for variable setting).
Variables & Keywords
This is a very important function that is in all programming languages. You can use this to store values, store lists of values, objects, and even to store code for later use!
var
This keyword defines a variable without any constrant. Example:
var str = "Hello World!"
let
This keyword defines a variable that can be changed, but not redefined.
const
This keyword defines a constant variable.
const
This keyword defines a constant variable.
function
Function keyword. This allows you to call a function (Reuse old code) later. Example:
function logHi() { gearWorks.log("Hi"); }
function forever() {}
In the case of the forever function, gearWorks will take whatever code you have defined in the brakets and repeat it forever.
Math
Used for representing irrational numbers, and running other mathematical functions.
Math.E
Returns Euler's number.
Math.PI
Returns PI.
Math.sin(float)
Sine function.
Math.cos(float)
Cosine function.
Math.tan(float)
Tangent function.
Math.sqrt(float)
Square root function.
Math.pow(x, y)
Returns x to the power of y.
Math.abs(float)
Absolute value function.
Math.round(float)
Rounding to nearest intager function.
Math.ceil(float)
Rounding up function.
Math.floor(float)
Rounding down function.
Math.random()
Returns random value between 0 and 1.
Extensions
ECI
The ECI (Extention Creation Interface) is used to create custom user extentions, which adds an extra layer of freedom to Gear Works. Extentions are "Mods" for the Gear Works editor that can add extra uses and improve user experience. You can access the ECI here.