whale-core

WhaleJS core library. It handles user input, windows, file system, graphics and more. Probably too much. It may be split into smaller libraries in the future.

Most of classes in this library are just thin wrappers around SDL and OpenGL.

class whale-core.Buffer()
class whale-core.Buffer(data)
Arguments:
  • data (String)

Represents a binary buffer.

It uses native platform’s endianness.

Buffer.pushFloat(data)
Arguments:
  • data (Number)

Buffer.pushInt8(data)
Arguments:
  • data (Number)

Buffer.pushInt16(data)
Arguments:
  • data (Number)

Buffer.pushInt32(data)
Arguments:
  • data (Number)

Buffer.pushUInt8(data)
Arguments:
  • data (Number)

Buffer.pushUInt16(data)
Arguments:
  • data (Number)

Buffer.pushUInt32(data)
Arguments:
  • data (Number)

Buffer.push(data)
Arguments:
Buffer.push(data)
Arguments:
Buffer.push(data)
Arguments:
Buffer.resize(size)
Arguments:
  • size (Number) – New size in bytes.

Buffer.reserve(capacity)
Arguments:
  • capacity (Number) – New capacity in bytes.

Reserves buffer memory. Guarantees buffer to be able to hold a specified amount of data without the need for reallocation.

It doesn’t affect the size of the buffer.

Buffer.size()
Return type:

Number

Returns buffer’s size in bytes.

Buffer.capacity()
Return type:

Number

Returns buffer’s capacity in bytes.

Buffer.empty()
Return type:

Boolean

Tells if buffer is empty.

Buffer.clear()

Clears the buffer.

After calling it, buffer will be empty. Buffer’s capacity won’t be affected.

Buffer.toString()
Return type:

String

Constructs a string from buffer’s contents.

class whale-core.BufferObject()
class whale-core.BufferObject(target, usage, data)
Arguments:

Represents an OpenGL buffer object.

BufferObject.Target
Type:

Object

BufferObject.Target.ARRAY
BufferObject.Target.ELEMENT_ARRAY
BufferObject.Usage
Type:

Object

BufferObject.Usage.DYNAMIC
BufferObject.Usage.STATIC
BufferObject.Usage.STREAM
class whale-core.Canvas(renderContext, size)
Arguments:

Represents a canvas which can be used to draw sprites and print text.

Canvas.draw(sprite)
Arguments:

Draws a sprite.

Canvas.draw(sprites)
Arguments:

Draws a batch of sprites.

Canvas.print(text, transform, color, font, height)
Arguments:

Prints text.

Canvas.scale
Type:

whale-core.Vec2

Canvas scale.

class whale-core.DMat2()
class whale-core.DMat2(diagonal)
Arguments:
  • diagonal (Number) – Value of the main diagonal.

class whale-core.DMat2(m)
Arguments:
class whale-core.DMat2(m)
Arguments:

Represents a double-precision 2x2 matrix.

By default, it creates a zero-initialized matrix.

DMat2.mul(m)
Arguments:
Return type:

whale-core.DMat2

DMat2.mul(v)
Arguments:
Return type:

whale-core.DVec2

DMat2.mul(n)
Arguments:
  • n (Number)

Return type:

whale-core.DMat2

DMat2.get(col, row)
Arguments:
  • col (Number) – Column index.

  • row (Number) – Row index.

Return type:

Number

Returns value of matrix element at given coordinates.

DMat2.set(col, row, value)
Arguments:
  • col (Number) – Column index.

  • row (Number) – Row index.

  • value (Number) – New element value.

Sets value of matrix element at given coordinates.

class whale-core.DMat3()
class whale-core.DMat3(diagonal)
Arguments:
  • diagonal (Number) – Value of the main diagonal.

class whale-core.DMat3(m)
Arguments:
class whale-core.DMat3(m)
Arguments:

Represents a double-precision 3x3 matrix.

By default, it creates a zero-initialized matrix.

DMat3.mul(m)
Arguments:
Return type:

whale-core.DMat3

DMat3.mul(v)
Arguments:
Return type:

whale-core.DVec3

DMat3.mul(n)
Arguments:
  • n (Number)

Return type:

whale-core.DMat3

DMat3.get(col, row)
Arguments:
  • col (Number) – Column index.

  • row (Number) – Row index.

Return type:

Number

Returns value of matrix element at given coordinates.

DMat3.set(col, row, value)
Arguments:
  • col (Number) – Column index.

  • row (Number) – Row index.

  • value (Number) – New element value.

Sets value of matrix element at given coordinates.

class whale-core.DMat4()
class whale-core.DMat4(diagonal)
Arguments:
  • diagonal (Number) – Value of the main diagonal.

class whale-core.DMat4(m)
Arguments:
class whale-core.DMat4(m)
Arguments:

Represents a double-precision 4x4 matrix.

By default, it creates a zero-initialized matrix.

DMat4.mul(m)
Arguments:
Return type:

whale-core.DMat4

DMat4.mul(v)
Arguments:
Return type:

whale-core.DVec4

DMat4.mul(n)
Arguments:
  • n (Number)

Return type:

whale-core.DMat4

DMat4.get(col, row)
Arguments:
  • col (Number) – Column index.

  • row (Number) – Row index.

Return type:

Number

Returns value of matrix element at given coordinates.

DMat4.set(col, row, value)
Arguments:
  • col (Number) – Column index.

  • row (Number) – Row index.

  • value (Number) – New element value.

Sets value of matrix element at given coordinates.

class whale-core.DRect2()
class whale-core.DRect2(a, b)
Arguments:

Represents a 2D rectangle defined by two points.

DRect2.a
Type:

whale-core.DVec2

DRect2.b
Type:

whale-core.DVec2

class whale-core.DRect3()
class whale-core.DRect3(a, b)
Arguments:

Represents a 3D rectangle defined by two points.

DRect3.a
Type:

whale-core.DVec3

DRect3.b
Type:

whale-core.DVec3

class whale-core.DRect4()
class whale-core.DRect4(a, b)
Arguments:

Represents a 4D rectangle defined by two points.

DRect4.a
Type:

whale-core.DVec4

DRect4.b
Type:

whale-core.DVec4

class whale-core.DVec1()
class whale-core.DVec1(v)
Arguments:
class whale-core.DVec1(v)
Arguments:
class whale-core.DVec1(v)
Arguments:
class whale-core.DVec1(v)
Arguments:
class whale-core.DVec1(x)
Arguments:
  • x (Number)

Represents a 1D vector.

DVec1.x
Type:

Number

DVec1.add(v)
Arguments:
Return type:

whale-core.DVec1

DVec1.add(n)
Arguments:
  • n (Number)

Return type:

whale-core.DVec1

DVec1.div(v)
Arguments:
Return type:

whale-core.DVec1

DVec1.div(n)
Arguments:
  • n (Number)

Return type:

whale-core.DVec1

DVec1.dot(v)
Arguments:
Return type:

Number

DVec1.get(index)
Arguments:
  • index (Number)

Return type:

Number

Returns a vector element under a given index.

DVec1.length()
Return type:

Number

Returns length of the vector.

DVec1.length2()
Return type:

Number

Returns squared length of the vector.

DVec1.mul(v)
Arguments:
Return type:

whale-core.DVec1

DVec1.mul(n)
Arguments:
  • n (Number)

Return type:

whale-core.DVec1

DVec1.neg()
Return type:

whale-core.DVec1

DVec1.normalize()
Return type:

whale-core.DVec1

DVec1.reflect(normal)
Arguments:
Return type:

whale-core.DVec1

DVec1.sub(v)
Arguments:
Return type:

whale-core.DVec1

DVec1.sub(n)
Arguments:
  • n (Number)

Return type:

whale-core.DVec1

class whale-core.DVec2()
class whale-core.DVec2(v)
Arguments:
class whale-core.DVec2(v)
Arguments:
class whale-core.DVec2(v)
Arguments:
class whale-core.DVec2(v)
Arguments:
class whale-core.DVec2(x)
Arguments:
  • x (Number)

class whale-core.DVec2(x, y)
Arguments:
  • x (Number)

  • y (Number)

Represents a 2D vector.

DVec2.x
Type:

Number

DVec2.y
Type:

Number

DVec2.s
Type:

Number

DVec2.t
Type:

Number

DVec2.add(v)
Arguments:
Return type:

whale-core.DVec2

DVec2.add(n)
Arguments:
  • n (Number)

Return type:

whale-core.DVec2

DVec2.div(v)
Arguments:
Return type:

whale-core.DVec2

DVec2.div(n)
Arguments:
  • n (Number)

Return type:

whale-core.DVec2

DVec2.dot(v)
Arguments:
Return type:

Number

DVec2.get(index)
Arguments:
  • index (Number)

Return type:

Number

Returns a vector element under a given index.

DVec2.length()
Return type:

Number

Returns length of the vector.

DVec2.length2()
Return type:

Number

Returns squared length of the vector.

DVec2.mul(v)
Arguments:
Return type:

whale-core.DVec2

DVec2.mul(n)
Arguments:
  • n (Number)

Return type:

whale-core.DVec2

DVec2.neg()
Return type:

whale-core.DVec2

DVec2.normalize()
Return type:

whale-core.DVec2

DVec2.reflect(normal)
Arguments:
Return type:

whale-core.DVec2

DVec2.sub(v)
Arguments:
Return type:

whale-core.DVec2

DVec2.sub(n)
Arguments:
  • n (Number)

Return type:

whale-core.DVec2

class whale-core.DVec3()
class whale-core.DVec3(v)
Arguments:
class whale-core.DVec3(v)
Arguments:
class whale-core.DVec3(v)
Arguments:
class whale-core.DVec3(v)
Arguments:
class whale-core.DVec3(x)
Arguments:
  • x (Number)

class whale-core.DVec3(x, y)
Arguments:
  • x (Number)

  • y (Number)

class whale-core.DVec3(x, y, x)
Arguments:
  • x (Number)

  • y (Number)

  • z (Number)

Represents a 3D vector.

DVec3.x
Type:

Number

DVec3.y
Type:

Number

DVec3.z
Type:

Number

DVec3.r
Type:

Number

DVec3.g
Type:

Number

DVec3.b
Type:

Number

DVec3.s
Type:

Number

DVec3.t
Type:

Number

DVec3.p
Type:

Number

DVec3.add(v)
Arguments:
Return type:

whale-core.DVec3

DVec3.add(n)
Arguments:
  • n (Number)

Return type:

whale-core.DVec3

DVec3.div(v)
Arguments:
Return type:

whale-core.DVec3

DVec3.div(n)
Arguments:
  • n (Number)

Return type:

whale-core.DVec3

DVec3.dot(v)
Arguments:
Return type:

Number

DVec3.get(index)
Arguments:
  • index (Number)

Return type:

Number

Returns a vector element under a given index.

DVec3.length()
Return type:

Number

Returns length of the vector.

DVec3.length2()
Return type:

Number

Returns squared length of the vector.

DVec3.mul(v)
Arguments:
Return type:

whale-core.DVec3

DVec3.mul(n)
Arguments:
  • n (Number)

Return type:

whale-core.DVec3

DVec3.neg()
Return type:

whale-core.DVec3

DVec3.normalize()
Return type:

whale-core.DVec3

DVec3.reflect(normal)
Arguments:
Return type:

whale-core.DVec3

DVec3.sub(v)
Arguments:
Return type:

whale-core.DVec3

DVec3.sub(n)
Arguments:
  • n (Number)

Return type:

whale-core.DVec3

class whale-core.DVec4()
class whale-core.DVec4(v)
Arguments:
class whale-core.DVec4(v)
Arguments:
class whale-core.DVec4(v)
Arguments:
class whale-core.DVec4(v)
Arguments:
class whale-core.DVec4(x)
Arguments:
  • x (Number)

class whale-core.DVec4(x, y)
Arguments:
  • x (Number)

  • y (Number)

class whale-core.DVec4(x, y, z)
Arguments:
  • x (Number)

  • y (Number)

  • z (Number)

class whale-core.DVec4(x, y, z, w)
Arguments:
  • x (Number)

  • y (Number)

  • z (Number)

  • w (Number)

Represents a 4D vector.

DVec4.x
Type:

Number

DVec4.y
Type:

Number

DVec4.z
Type:

Number

DVec4.w
Type:

Number

DVec4.r
Type:

Number

DVec4.g
Type:

Number

DVec4.b
Type:

Number

DVec4.a
Type:

Number

DVec4.s
Type:

Number

DVec4.t
Type:

Number

DVec4.p
Type:

Number

DVec4.q
Type:

Number

DVec4.add(v)
Arguments:
Return type:

whale-core.DVec4

DVec4.add(n)
Arguments:
  • n (Number)

Return type:

whale-core.DVec4

DVec4.div(v)
Arguments:
Return type:

whale-core.DVec4

DVec4.div(n)
Arguments:
  • n (Number)

Return type:

whale-core.DVec4

DVec4.dot(v)
Arguments:
Return type:

Number

DVec4.get(index)
Arguments:
  • index (Number)

Return type:

Number

Returns a vector element under a given index.

DVec4.length()
Return type:

Number

Returns length of the vector.

DVec4.length2()
Return type:

Number

Returns squared length of the vector.

DVec4.mul(v)
Arguments:
Return type:

whale-core.DVec4

DVec4.mul(n)
Arguments:
  • n (Number)

Return type:

whale-core.DVec4

DVec4.neg()
Return type:

whale-core.DVec4

DVec4.normalize()
Return type:

whale-core.DVec4

DVec4.reflect(normal)
Arguments:
Return type:

whale-core.DVec4

DVec4.sub(v)
Arguments:
Return type:

whale-core.DVec4

DVec4.sub(n)
Arguments:
  • n (Number)

Return type:

whale-core.DVec4

class whale-core.Event(event)
Arguments:
class whale-core.Event(event)
Arguments:
class whale-core.Event(event)
Arguments:
class whale-core.Event(event)
Arguments:
class whale-core.Event(event)
Arguments:
Event.type
Type:

Number

Event.keyPress
Type:

whale-core.KeyPress

Event.mouseMove
Type:

whale-core.MouseMove

Event.mouseButton
Type:

whale-core.MouseButton

Event.mouseWheel
Type:

whale-core.MouseWheel

Event.Type
Type:

Object

Event.Type.KEY_PRESS
Event.Type.MOUSE_MOVE
Event.Type.MOUSE_BUTTON
Event.Type.MOUSE_WHEEL
Event.Type.QUIT
Event.Type.NULL
class whale-core.File()

Represents a file.

File.read()
Return type:

whale-core.Buffer

Reads file contents to a buffer.

File.write(buffer)
Arguments:
Return type:

Number

Returns:

Number of written bytes.

Writes contents of a buffer to the file.

File.write(buffer, count)
Arguments:
Return type:

Number

Returns:

Number of written bytes.

Writes contents of a buffer to the file.

File.Mode
Type:

Object

File.Mode.READ
File.Mode.WRITE
File.Mode.APPEND
File.Mode.BINARY
File.Mode.TEXT
class whale-core.Font()

Represents a font.

Font.addChar(code, page, uv, size, offset, xAdvance)
Arguments:
  • code (Number) – Unicode character code.

  • page (Number) – Font page number.

  • uv (whale-core.Rect2) – UV coordinates of a character glyph on the font page.

  • size (whale-core.IVec2) – Font size (in pixels).

  • offset (whale-core.IVec2) – Offset to the current position when drawing a character (in pixels).

  • xAdvance (Number) – Distance the current X position will be advanced after drawing a character (in pixels).

Font.addPage(image)
Arguments:
Font.addKerningPair(first, second, offset)
Arguments:
  • first (Number) – Unicode character code of the first character.

  • second (Number) – Unicode character code of the second character.

  • offset (Number) – Offset between the characters.

Font.lineHeight
Type:

Number

Height of font line.

class whale-core.FrameBuffer(texture)
Arguments:

Represents an OpenGL frame buffer.

class whale-core.Image(imageInfo, buffer)
Arguments:

Represents an image.

Image.pixel(position)
Arguments:
Return type:

whale-core.Vec4

Returns a color of an image pixel at the specified coordinates.

class whale-core.ImageInfo(format, width, height)
Arguments:

Represents information about an image.

ImageInfo.Format
Type:

Object

ImageInfo.Format.RGB
ImageInfo.Format.RGBA
class whale-core.IVec1()
class whale-core.IVec1(v)
Arguments:
class whale-core.IVec1(v)
Arguments:
class whale-core.IVec1(v)
Arguments:
class whale-core.IVec1(v)
Arguments:
class whale-core.IVec1(x)
Arguments:
  • x (Number)

Represents a 1D vector.

IVec1.x
Type:

Number

IVec1.add(v)
Arguments:
Return type:

whale-core.IVec1

IVec1.add(n)
Arguments:
  • n (Number)

Return type:

whale-core.IVec1

IVec1.div(v)
Arguments:
Return type:

whale-core.IVec1

IVec1.div(n)
Arguments:
  • n (Number)

Return type:

whale-core.IVec1

IVec1.get(index)
Arguments:
  • index (Number)

Return type:

Number

Returns a vector element under a given index.

IVec1.mul(v)
Arguments:
Return type:

whale-core.IVec1

IVec1.mul(n)
Arguments:
  • n (Number)

Return type:

whale-core.IVec1

IVec1.neg()
Return type:

whale-core.IVec1

IVec1.sub(v)
Arguments:
Return type:

whale-core.IVec1

IVec1.sub(n)
Arguments:
  • n (Number)

Return type:

whale-core.IVec1

class whale-core.IVec2()
class whale-core.IVec2(v)
Arguments:
class whale-core.IVec2(v)
Arguments:
class whale-core.IVec2(v)
Arguments:
class whale-core.IVec2(v)
Arguments:
class whale-core.IVec2(x)
Arguments:
  • x (Number)

class whale-core.IVec2(x, y)
Arguments:
  • x (Number)

  • y (Number)

Represents a 2D vector.

IVec2.x
Type:

Number

IVec2.y
Type:

Number

IVec2.s
Type:

Number

IVec2.t
Type:

Number

IVec2.add(v)
Arguments:
Return type:

whale-core.IVec2

IVec2.add(n)
Arguments:
  • n (Number)

Return type:

whale-core.IVec2

IVec2.div(v)
Arguments:
Return type:

whale-core.IVec2

IVec2.div(n)
Arguments:
  • n (Number)

Return type:

whale-core.IVec2

IVec2.get(index)
Arguments:
  • index (Number)

Return type:

Number

Returns a vector element under a given index.

IVec2.mul(v)
Arguments:
Return type:

whale-core.IVec2

IVec2.mul(n)
Arguments:
  • n (Number)

Return type:

whale-core.IVec2

IVec2.neg()
Return type:

whale-core.IVec2

IVec2.sub(v)
Arguments:
Return type:

whale-core.IVec2

IVec2.sub(n)
Arguments:
  • n (Number)

Return type:

whale-core.IVec2

class whale-core.IVec3()
class whale-core.IVec3(v)
Arguments:
class whale-core.IVec3(v)
Arguments:
class whale-core.IVec3(v)
Arguments:
class whale-core.IVec3(v)
Arguments:
class whale-core.IVec3(x)
Arguments:
  • x (Number)

class whale-core.IVec3(x, y)
Arguments:
  • x (Number)

  • y (Number)

class whale-core.IVec3(x, y, z)
Arguments:
  • x (Number)

  • y (Number)

  • z (Number)

Represents a 3D vector.

IVec3.x
Type:

Number

IVec3.y
Type:

Number

IVec3.z
Type:

Number

IVec3.r
Type:

Number

IVec3.g
Type:

Number

IVec3.b
Type:

Number

IVec3.s
Type:

Number

IVec3.t
Type:

Number

IVec3.p
Type:

Number

IVec3.add(v)
Arguments:
Return type:

whale-core.IVec3

IVec3.add(n)
Arguments:
  • n (Number)

Return type:

whale-core.IVec3

IVec3.div(v)
Arguments:
Return type:

whale-core.IVec3

IVec3.div(n)
Arguments:
  • n (Number)

Return type:

whale-core.IVec3

IVec3.get(index)
Arguments:
  • index (Number)

Return type:

Number

Returns a vector element under a given index.

IVec3.mul(v)
Arguments:
Return type:

whale-core.IVec3

IVec3.mul(n)
Arguments:
  • n (Number)

Return type:

whale-core.IVec3

IVec3.neg()
Return type:

whale-core.IVec3

IVec3.sub(v)
Arguments:
Return type:

whale-core.IVec3

IVec3.sub(n)
Arguments:
  • n (Number)

Return type:

whale-core.IVec3

class whale-core.IVec4()
class whale-core.IVec4(v)
Arguments:
class whale-core.IVec4(v)
Arguments:
class whale-core.IVec4(v)
Arguments:
class whale-core.IVec4(v)
Arguments:
class whale-core.IVec4(x)
Arguments:
  • x (Number)

class whale-core.IVec4(x, y)
Arguments:
  • x (Number)

  • y (Number)

class whale-core.IVec4(x, y, z)
Arguments:
  • x (Number)

  • y (Number)

  • z (Number)

class whale-core.IVec4(x, y, z, w)
Arguments:
  • x (Number)

  • y (Number)

  • z (Number)

  • w (Number)

Represents a 4D vector.

IVec4.x
Type:

Number

IVec4.y
Type:

Number

IVec4.z
Type:

Number

IVec4.w
Type:

Number

IVec4.r
Type:

Number

IVec4.g
Type:

Number

IVec4.b
Type:

Number

IVec4.a
Type:

Number

IVec4.s
Type:

Number

IVec4.t
Type:

Number

IVec4.p
Type:

Number

IVec4.q
Type:

Number

IVec4.add(v)
Arguments:
Return type:

whale-core.IVec4

IVec4.add(n)
Arguments:
  • n (Number)

Return type:

whale-core.IVec4

IVec4.div(v)
Arguments:
Return type:

whale-core.IVec4

IVec4.div(n)
Arguments:
  • n (Number)

Return type:

whale-core.IVec4

IVec4.get(index)
Arguments:
  • index (Number)

Return type:

Number

Returns a vector element under a given index.

IVec4.mul(v)
Arguments:
Return type:

whale-core.IVec4

IVec4.mul(n)
Arguments:
  • n (Number)

Return type:

whale-core.IVec4

IVec4.neg()
Return type:

whale-core.IVec4

IVec4.sub(v)
Arguments:
Return type:

whale-core.IVec4

IVec4.sub(n)
Arguments:
  • n (Number)

Return type:

whale-core.IVec4

class whale-core.KeyPress(state, code, modifier)
Arguments:

Represents key press event.

KeyPress.state
Type:

whale-core.KeyPress.State

KeyPress.code
Type:

whale-core.KeyPress.Code

KeyPress.modifier
Type:

whale-core.KeyPress.Modifier

KeyPress.State
Type:

Object

KeyPress.State.UP
KeyPress.State.DOWN
KeyPress.Code
Type:

Object

KeyPress.Code.ENTER
KeyPress.Code.ESCAPE
KeyPress.Code.BACKSPACE
KeyPress.Code.TAB
KeyPress.Code.SPACE
KeyPress.Code.EXCLAMATION
KeyPress.Code.DOUBLE_QUOTE
KeyPress.Code.HASH
KeyPress.Code.PERCENT
KeyPress.Code.DOLLAR
KeyPress.Code.AMPERSAND
KeyPress.Code.QUOTE
KeyPress.Code.LEFT_PARENTHESIS
KeyPress.Code.RIGHT_PARENTHESIS
KeyPress.Code.ASTERISK
KeyPress.Code.PLUS
KeyPress.Code.COMMA
KeyPress.Code.MINUS
KeyPress.Code.PERIOD
KeyPress.Code.SLASH
KeyPress.Code.ZERO
KeyPress.Code.ONE
KeyPress.Code.TWO
KeyPress.Code.THREE
KeyPress.Code.FOUR
KeyPress.Code.FIVE
KeyPress.Code.SIX
KeyPress.Code.SEVEN
KeyPress.Code.EIGHT
KeyPress.Code.NINE
KeyPress.Code.COLON
KeyPress.Code.SEMICOLON
KeyPress.Code.LESS
KeyPress.Code.EQUALS
KeyPress.Code.GREATER
KeyPress.Code.QUESTION
KeyPress.Code.AT
KeyPress.Code.LEFT_BRACKET
KeyPress.Code.BACKSLASH
KeyPress.Code.RIGHT_BRACKET
KeyPress.Code.CARET
KeyPress.Code.UNDERSCORE
KeyPress.Code.BACKQUOTE
KeyPress.Code.A
KeyPress.Code.B
KeyPress.Code.C
KeyPress.Code.D
KeyPress.Code.E
KeyPress.Code.F
KeyPress.Code.G
KeyPress.Code.H
KeyPress.Code.I
KeyPress.Code.J
KeyPress.Code.K
KeyPress.Code.L
KeyPress.Code.M
KeyPress.Code.N
KeyPress.Code.O
KeyPress.Code.P
KeyPress.Code.Q
KeyPress.Code.R
KeyPress.Code.S
KeyPress.Code.T
KeyPress.Code.U
KeyPress.Code.V
KeyPress.Code.W
KeyPress.Code.X
KeyPress.Code.Y
KeyPress.Code.Z
KeyPress.Modifier
Type:

Object

KeyPress.Modifier.NONE
KeyPress.Modifier.SHIFT_LEFT
KeyPress.Modifier.SHIFT_RIGHT
KeyPress.Modifier.SHIFT
KeyPress.Modifier.CTRL_LEFT
KeyPress.Modifier.CTRL_RIGHT
KeyPress.Modifier.CTRL
KeyPress.Modifier.ALT_LEFT
KeyPress.Modifier.ALT_RIGHT
KeyPress.Modifier.ALT
KeyPress.Modifier.NUM_LOCK
KeyPress.Modifier.CAPS_LOCK
class whale-core.LocalFileSystem()
class whale-core.LocalFileSystem(rootPath)
Arguments:
  • rootPath (String) – Path to the root directory.

Represents the local file system.

By default, root of the local file system is located in the project directory.

LocalFileSystem.openFile(path)
Arguments:
  • path (String)

Return type:

whale-core.File

Opens a file in binary read mode.

LocalFileSystem.openFile(path, fileMode)
Arguments:
Return type:

whale-core.File

Opens a file in the specified mode.

LocalFileSystem.openDirectory(path)
Arguments:
  • path (String)

Return type:

whale-core.Directory

Opens a directory.

LocalFileSystem.isFile(path)
Arguments:
  • path (String)

Return type:

Boolean

Tells if a given path points to a file.

LocalFileSystem.isDirectory(path)
Arguments:
  • path (String)

Return type:

Boolean

Tells if a given path points to a directory.

class whale-core.Mat2()
class whale-core.Mat2(diagonal)
Arguments:
  • diagonal (Number) – Value of the main diagonal.

class whale-core.Mat2(m)
Arguments:
class whale-core.Mat2(m)
Arguments:

Represents a single-precision 2x2 matrix.

By default, it creates a zero-initialized matrix.

Mat2.mul(m)
Arguments:
Return type:

whale-core.Mat2

Mat2.mul(v)
Arguments:
Return type:

whale-core.Vec2

Mat2.mul(n)
Arguments:
  • n (Number)

Return type:

whale-core.Mat2

Mat2.get(col, row)
Arguments:
  • col (Number) – Column index.

  • row (Number) – Row index.

Return type:

Number

Returns value of matrix element at given coordinates.

Mat2.set(col, row, value)
Arguments:
  • col (Number) – Column index.

  • row (Number) – Row index.

  • value (Number) – New element value.

Sets value of matrix element at given coordinates.

class whale-core.Mat3()
class whale-core.Mat3(diagonal)
Arguments:
  • diagonal (Number) – Value of the main diagonal.

class whale-core.Mat3(m)
Arguments:
class whale-core.Mat3(m)
Arguments:

Represents a single-precision 3x3 matrix.

By default, it creates a zero-initialized matrix.

Mat3.mul(m)
Arguments:
Return type:

whale-core.Mat3

Mat3.mul(v)
Arguments:
Return type:

whale-core.Vec3

Mat3.mul(n)
Arguments:
  • n (Number)

Return type:

whale-core.Mat3

Mat3.get(col, row)
Arguments:
  • col (Number) – Column index.

  • row (Number) – Row index.

Return type:

Number

Returns value of matrix element at given coordinates.

Mat3.set(col, row, value)
Arguments:
  • col (Number) – Column index.

  • row (Number) – Row index.

  • value (Number) – New element value.

Sets value of matrix element at given coordinates.

class whale-core.Mat4()
class whale-core.Mat4(diagonal)
Arguments:
  • diagonal (Number) – Value of the main diagonal.

class whale-core.Mat4(m)
Arguments:
class whale-core.Mat4(m)
Arguments:

Represents a single-precision 4x4 matrix.

By default, it creates a zero-initialized matrix.

Mat4.mul(m)
Arguments:
Return type:

whale-core.Mat4

Mat4.mul(v)
Arguments:
Return type:

whale-core.Vec4

Mat4.mul(n)
Arguments:
  • n (Number)

Return type:

whale-core.Mat4

Mat4.get(col, row)
Arguments:
  • col (Number) – Column index.

  • row (Number) – Row index.

Return type:

Number

Returns value of matrix element at given coordinates.

Mat4.set(col, row, value)
Arguments:
  • col (Number) – Column index.

  • row (Number) – Row index.

  • value (Number) – New element value.

Sets value of matrix element at given coordinates.

class whale-core.MouseButton(id, state)
Arguments:

Represents a mouse button event.

MouseButton.id
Type:

whale-core.MouseButton.Id

MouseButton.state
Type:

whale-core.MouseButton.State

MouseButton.Id
Type:

Object

MouseButton.Id.LEFT
MouseButton.Id.MIDDLE
MouseButton.Id.RIGHT
MouseButton.Id.X1
MouseButton.Id.X2
MouseButton.State
Type:

Object

MouseButton.State.UP
MouseButton.State.DOWN
class whale-core.MouseMove(position, relativePosition)
Arguments:

Represents a mouse move event.

MouseMove.position
Type:

whale-core.UVec2

MouseMove.relativePosition
Type:

whale-core.IVec2

class whale-core.MouseWheel(x, y)
Arguments:
  • x (Number)

  • y (Number)

Represents a mouse wheel event.

MouseWheel.x
Type:

Number

MouseWheel.y
Type:

Number

class whale-core.Program(shaderA, shaderB)
Arguments:

Represents an OpenGL program.

It links two supplied shaders.

class whale-core.QuitEvent()

Represents quit event.

class whale-core.Rect2()
class whale-core.Rect2(a, b)
Arguments:

Represents a 2D rectangle defined by two points.

Rect2.a
Type:

whale-core.Vec2

Rect2.b
Type:

whale-core.Vec2

class whale-core.Rect3()
class whale-core.Rect3(a, b)
Arguments:

Represents a 3D rectangle defined by two points.

Rect3.a
Type:

whale-core.Vec3

Rect3.b
Type:

whale-core.Vec3

class whale-core.Rect4()
class whale-core.Rect4(a, b)
Arguments:

Represents a 4D rectangle defined by two points.

Rect4.a
Type:

whale-core.Vec4

Rect4.b
Type:

whale-core.Vec4

class whale-core.RenderContext(window)
Arguments:

Represents an OpenGL render context.

RenderContext.window()
Return type:

whale-core.Window

RenderContext.use(bufferObject)
Arguments:

Use specified OpenGL buffer object.

RenderContext.use(frameBuffer)
Arguments:

Use specified OpenGL frame buffer.

RenderContext.use(program)
Arguments:

Use specified OpenGL program.

RenderContext.use(attrList)
Arguments:

Use specified OpenGL vertex attribute list.

RenderContext.use(uniformSet)
Arguments:

Use specified OpenGL uniform set.

RenderContext.useDefaultFrameBuffer()
RenderContext.blending(enabled)
Arguments:
  • enabled (Boolean)

Enables or disables OpenGL blending.

RenderContext.blendingMode(source, destination)
Arguments:

Sets OpenGL blending mode.

RenderContext.BlendingMode
Type:

Object

RenderContext.BlendingMode.ZERO
RenderContext.BlendingMode.ONE
RenderContext.BlendingMode.SOURCE_COLOR
RenderContext.BlendingMode.ONE_MINUS_SOURCE_COLOR
RenderContext.BlendingMode.DESTINATION_COLOR
RenderContext.BlendingMode.ONE_MINUS_DESTINATION_COLOR
RenderContext.BlendingMode.SOURCE_ALPHA
RenderContext.BlendingMode.ONE_MINUS_SOURCE_ALPHA
RenderContext.BlendingMode.DESTINATION_ALPHA
RenderContext.BlendingMode.ONE_MINUS_DESTINATION_ALPHA
RenderContext.BlendingMode.CONSTANT_COLOR
RenderContext.BlendingMode.ONE_MINUS_CONSTANT_COLOR
RenderContext.BlendingMode.CONSTANT_ALPHA
RenderContext.BlendingMode.ONE_MINUS_CONSTANT_ALPHA
RenderContext.BlendingMode.SOURCE_ALPHA_SATURATE
RenderContext.draw(primitiveType, indexType, primitiveCount)
Arguments:
RenderContext.clear(color)
Arguments:
RenderContext.PrimitiveType
Type:

Object

RenderContext.PrimitiveType.POINTS
RenderContext.PrimitiveType.LINE_STRIP
RenderContext.PrimitiveType.LINE_LOOP
RenderContext.PrimitiveType.LINES
RenderContext.PrimitiveType.TRIANGLE_STRIP
RenderContext.PrimitiveType.TRIANGLE_FAN
RenderContext.PrimitiveType.TRIANGLES
RenderContext.IndexType
Type:

Object

RenderContext.IndexType.UNSIGNED_BYTE
RenderContext.IndexType.UNSIGNED_SHORT
class whale-core.Shader(type, source)
Arguments:
class whale-core.Shader(type, source)
Arguments:

Represents an OpenGL shader.

Shader.Type
Type:

Object

Shader.Type.VERTEX
Shader.Type.FRAGMENT
class whale-core.Sprite(sprite)
Arguments:
class whale-core.Sprite(texture, transform, size)
Arguments:

Represents a canvas sprite.

Sprite.texture
Type:

whale-core.Texture

Sprite.uv
Type:

whale-core.Rect2

Sprite.color
Type:

whale-core.Vec4

Sprite.size
Type:

whale-core.Vec2

Sprite.transform
Type:

whale-core.Mat3

class whale-core.SpriteSheet(spriteMap, texture)
Arguments:

Represents a sprite sheet.

SpriteSheet.sprite(name)
Arguments:
  • name (String)

Return type:

whale-core.Sprite

class whale-core.Texture(image)
Arguments:
class whale-core.Texture(imageInfo)
Arguments:

Represents an OpenGL texture.

class whale-core.Uniform(n)
Arguments:
  • n (Number)

class whale-core.Uniform(v)
Arguments:
class whale-core.Uniform(v)
Arguments:
class whale-core.Uniform(v)
Arguments:
class whale-core.Uniform(m)
Arguments:
class whale-core.Uniform(m)
Arguments:
class whale-core.Uniform(m)
Arguments:
class whale-core.Uniform(texture)
Arguments:

Represents an OpenGL uniform.

class whale-core.UniformSet()

Represents an OpenGL uniform set.

UniformSet.set(name, uniform)
Arguments:
class whale-core.UVec1()
class whale-core.UVec1(v)
Arguments:
class whale-core.UVec1(v)
Arguments:
class whale-core.UVec1(v)
Arguments:
  • whale-core.IVec1

class whale-core.UVec1(v)
Arguments:
class whale-core.UVec1(x)
Arguments:
  • x (Number)

Represents a 1D vector.

UVec1.x
Type:

Number

UVec1.add(v)
Arguments:
Return type:

whale-core.UVec1

UVec1.add(n)
Arguments:
  • n (Number)

Return type:

whale-core.UVec1

UVec1.div(v)
Arguments:
Return type:

whale-core.UVec1

UVec1.div(n)
Arguments:
  • n (Number)

Return type:

whale-core.UVec1

UVec1.get(index)
Arguments:
  • index (Number)

Return type:

Number

Returns a vector element under a given index.

UVec1.mul(v)
Arguments:
Return type:

whale-core.UVec1

UVec1.mul(n)
Arguments:
  • n (Number)

Return type:

whale-core.UVec1

UVec1.neg()
Return type:

whale-core.UVec1

UVec1.sub(v)
Arguments:
Return type:

whale-core.UVec1

UVec1.sub(n)
Arguments:
  • n (Number)

Return type:

whale-core.UVec1

class whale-core.UVec2()
class whale-core.UVec2(v)
Arguments:
class whale-core.UVec2(v)
Arguments:
class whale-core.UVec2(v)
Arguments:
class whale-core.UVec2(v)
Arguments:
class whale-core.UVec2(x)
Arguments:
  • x (Number)

class whale-core.UVec2(x, y)
Arguments:
  • x (Number)

  • y (Number)

Represents a 2D vector.

UVec2.x
Type:

Number

UVec2.y
Type:

Number

UVec2.s
Type:

Number

UVec2.t
Type:

Number

UVec2.add(v)
Arguments:
Return type:

whale-core.UVec2

UVec2.add(n)
Arguments:
  • n (Number)

Return type:

whale-core.UVec2

UVec2.div(v)
Arguments:
Return type:

whale-core.UVec2

UVec2.div(n)
Arguments:
  • n (Number)

Return type:

whale-core.UVec2

UVec2.get(index)
Arguments:
  • index (Number)

Return type:

Number

Returns a vector element under a given index.

UVec2.mul(v)
Arguments:
Return type:

whale-core.UVec2

UVec2.mul(n)
Arguments:
  • n (Number)

Return type:

whale-core.UVec2

UVec2.neg()
Return type:

whale-core.UVec2

UVec2.sub(v)
Arguments:
Return type:

whale-core.UVec2

UVec2.sub(n)
Arguments:
  • n (Number)

Return type:

whale-core.UVec2

class whale-core.UVec3()
class whale-core.UVec3(v)
Arguments:
class whale-core.UVec3(v)
Arguments:
class whale-core.UVec3(v)
Arguments:
class whale-core.UVec3(v)
Arguments:
class whale-core.UVec3(x)
Arguments:
  • x (Number)

class whale-core.UVec3(x, y)
Arguments:
  • x (Number)

  • y (Number)

class whale-core.UVec3(x, y, z)
Arguments:
  • x (Number)

  • y (Number)

  • z (Number)

Represents a 3D vector.

UVec3.x
Type:

Number

UVec3.y
Type:

Number

UVec3.z
Type:

Number

UVec3.r
Type:

Number

UVec3.g
Type:

Number

UVec3.b
Type:

Number

UVec3.s
Type:

Number

UVec3.t
Type:

Number

UVec3.p
Type:

Number

UVec3.add(v)
Arguments:
Return type:

whale-core.UVec3

UVec3.add(n)
Arguments:
  • n (Number)

Return type:

whale-core.UVec3

UVec3.div(v)
Arguments:
Return type:

whale-core.UVec3

UVec3.div(n)
Arguments:
  • n (Number)

Return type:

whale-core.UVec3

UVec3.get(index)
Arguments:
  • index (Number)

Return type:

Number

Returns a vector element under a given index.

UVec3.mul(v)
Arguments:
Return type:

whale-core.UVec3

UVec3.mul(n)
Arguments:
  • n (Number)

Return type:

whale-core.UVec3

UVec3.neg()
Return type:

whale-core.UVec3

UVec3.sub(v)
Arguments:
Return type:

whale-core.UVec3

UVec3.sub(n)
Arguments:
  • n (Number)

Return type:

whale-core.UVec3

class whale-core.UVec4()
class whale-core.UVec4(v)
Arguments:
class whale-core.UVec4(v)
Arguments:
class whale-core.UVec4(v)
Arguments:
class whale-core.UVec4(v)
Arguments:
class whale-core.UVec4(x)
Arguments:
  • x (Number)

class whale-core.UVec4(x, y)
Arguments:
  • x (Number)

  • y (Number)

class whale-core.UVec4(x, y, z)
Arguments:
  • x (Number)

  • y (Number)

  • z (Number)

class whale-core.UVec4(x, y, z, w)
Arguments:
  • x (Number)

  • y (Number)

  • z (Number)

  • w (Number)

Represents a 4D vector.

UVec4.x
Type:

Number

UVec4.y
Type:

Number

UVec4.z
Type:

Number

UVec4.w
Type:

Number

UVec4.r
Type:

Number

UVec4.g
Type:

Number

UVec4.b
Type:

Number

UVec4.a
Type:

Number

UVec4.s
Type:

Number

UVec4.t
Type:

Number

UVec4.p
Type:

Number

UVec4.q
Type:

Number

UVec4.add(v)
Arguments:
Return type:

whale-core.UVec4

UVec4.add(n)
Arguments:
  • n (Number)

Return type:

whale-core.UVec4

UVec4.div(v)
Arguments:
Return type:

whale-core.UVec4

UVec4.div(n)
Arguments:
  • n (Number)

Return type:

whale-core.UVec4

UVec4.get(index)
Arguments:
  • index (Number)

Return type:

Number

Returns a vector element under a given index.

UVec4.mul(v)
Arguments:
Return type:

whale-core.UVec4

UVec4.mul(n)
Arguments:
  • n (Number)

Return type:

whale-core.UVec4

UVec4.neg()
Return type:

whale-core.UVec4

UVec4.sub(v)
Arguments:
Return type:

whale-core.UVec4

UVec4.sub(n)
Arguments:
  • n (Number)

Return type:

whale-core.UVec4

class whale-core.Vec1()
class whale-core.Vec1(v)
Arguments:
class whale-core.Vec1(v)
Arguments:
class whale-core.Vec1(v)
Arguments:
class whale-core.Vec1(v)
Arguments:
class whale-core.Vec1(x)
Arguments:
  • x (Number)

Represents a 1D vector.

Vec1.x
Type:

Number

Vec1.add(v)
Arguments:
Return type:

whale-core.Vec1

Vec1.add(n)
Arguments:
  • n (Number)

Return type:

whale-core.Vec1

Vec1.div(v)
Arguments:
Return type:

whale-core.Vec1

Vec1.div(n)
Arguments:
  • n (Number)

Return type:

whale-core.Vec1

Vec1.dot(v)
Arguments:
Return type:

Number

Vec1.get(index)
Arguments:
  • index (Number)

Return type:

Number

Returns a vector element under a given index.

Vec1.length()
Return type:

Number

Returns length of the vector.

Vec1.length2()
Return type:

Number

Returns squared length of the vector.

Vec1.mul(v)
Arguments:
Return type:

whale-core.Vec1

Vec1.mul(n)
Arguments:
  • n (Number)

Return type:

whale-core.Vec1

Vec1.neg()
Return type:

whale-core.Vec1

Vec1.normalize()
Return type:

whale-core.Vec1

Vec1.reflect(normal)
Arguments:
Return type:

whale-core.Vec1

Vec1.sub(v)
Arguments:
Return type:

whale-core.Vec1

Vec1.sub(n)
Arguments:
  • n (Number)

Return type:

whale-core.Vec1

class whale-core.Vec2()
class whale-core.Vec2(v)
Arguments:
class whale-core.Vec2(v)
Arguments:
class whale-core.Vec2(v)
Arguments:
class whale-core.Vec2(v)
Arguments:
class whale-core.Vec2(x)
Arguments:
  • x (Number)

class whale-core.Vec2(x, y)
Arguments:
  • x (Number)

  • y (Number)

Vec2.x
Type:

Number

Vec2.y
Type:

Number

Vec2.s
Type:

Number

Vec2.t
Type:

Number

Vec2.add(v)
Arguments:
Return type:

whale-core.Vec2

Vec2.add(n)
Arguments:
  • n (Number)

Return type:

whale-core.Vec2

Vec2.div(v)
Arguments:
Return type:

whale-core.Vec2

Vec2.div(n)
Arguments:
  • n (Number)

Return type:

whale-core.Vec2

Vec2.dot(v)
Arguments:
Return type:

Number

Vec2.get(index)
Arguments:
  • index (Number)

Return type:

Number

Returns a vector element under a given index.

Vec2.length()
Return type:

Number

Returns length of the vector.

Vec2.length2()
Return type:

Number

Returns squared length of the vector.

Vec2.mul(v)
Arguments:
Return type:

whale-core.Vec2

Vec2.mul(n)
Arguments:
  • n (Number)

Return type:

whale-core.Vec2

Vec2.neg()
Return type:

whale-core.Vec2

Vec2.normalize()
Return type:

whale-core.Vec2

Vec2.reflect(normal)
Arguments:
Return type:

whale-core.Vec2

Vec2.sub(v)
Arguments:
Return type:

whale-core.Vec2

Vec2.sub(n)
Arguments:
  • n (Number)

Return type:

whale-core.Vec2

class whale-core.Vec3()
class whale-core.Vec3(v)
Arguments:
class whale-core.Vec3(v)
Arguments:
class whale-core.Vec3(v)
Arguments:
class whale-core.Vec3(v)
Arguments:
class whale-core.Vec3(x)
Arguments:
  • x (Number)

class whale-core.Vec3(x, y)
Arguments:
  • x (Number)

  • y (Number)

class whale-core.Vec3(x, y, z)
Arguments:
  • x (Number)

  • y (Number)

  • z (Number)

Represents a 3D vector.

Vec3.x
Type:

Number

Vec3.y
Type:

Number

Vec3.z
Type:

Number

Vec3.r
Type:

Number

Vec3.g
Type:

Number

Vec3.b
Type:

Number

Vec3.s
Type:

Number

Vec3.t
Type:

Number

Vec3.p
Type:

Number

Vec3.add(v)
Arguments:
Return type:

whale-core.Vec3

Vec3.add(n)
Arguments:
  • n (Number)

Return type:

whale-core.Vec3

Vec3.div(v)
Arguments:
Return type:

whale-core.Vec3

Vec3.div(n)
Arguments:
  • n (Number)

Return type:

whale-core.Vec3

Vec3.dot(v)
Arguments:
Return type:

Number

Vec3.get(index)
Arguments:
  • index (Number)

Return type:

Number

Returns a vector element under a given index.

Vec3.length()
Return type:

Number

Returns length of the vector.

Vec3.length2()
Return type:

Number

Returns squared length of the vector.

Vec3.mul(v)
Arguments:
Return type:

whale-core.Vec3

Vec3.mul(n)
Arguments:
  • n (Number)

Return type:

whale-core.Vec3

Vec3.neg()
Return type:

whale-core.Vec3

Vec3.normalize()
Return type:

whale-core.Vec3

Vec3.reflect(normal)
Arguments:
Return type:

whale-core.Vec3

Vec3.sub(v)
Arguments:
Return type:

whale-core.Vec3

Vec3.sub(n)
Arguments:
  • n (Number)

Return type:

whale-core.Vec3

class whale-core.Vec4()
class whale-core.Vec4(v)
Arguments:
class whale-core.Vec4(v)
Arguments:
class whale-core.Vec4(v)
Arguments:
class whale-core.Vec4(v)
Arguments:
class whale-core.Vec4(x)
Arguments:
  • x (Number)

class whale-core.Vec4(x, y)
Arguments:
  • x (Number)

  • y (Number)

class whale-core.Vec4(x, y, z)
Arguments:
  • x (Number)

  • y (Number)

  • z (Number)

class whale-core.Vec4(x, y, z, w)
Arguments:
  • x (Number)

  • y (Number)

  • z (Number)

  • w (Number)

Represents a 4D vector.

Vec4.x
Type:

Number

Vec4.y
Type:

Number

Vec4.z
Type:

Number

Vec4.w
Type:

Number

Vec4.r
Type:

Number

Vec4.g
Type:

Number

Vec4.b
Type:

Number

Vec4.a
Type:

Number

Vec4.s
Type:

Number

Vec4.t
Type:

Number

Vec4.p
Type:

Number

Vec4.q
Type:

Number

Vec4.add(v)
Arguments:
Return type:

whale-core.Vec4

Vec4.add(n)
Arguments:
  • n (Number)

Return type:

whale-core.Vec4

Vec4.div(v)
Arguments:
Return type:

whale-core.Vec4

Vec4.div(n)
Arguments:
  • n (Number)

Return type:

whale-core.Vec4

Vec4.dot(v)
Arguments:
Return type:

Number

Vec4.get(index)
Arguments:
  • index (Number)

Return type:

Number

Returns a vector element under a given index.

Vec4.length()
Return type:

Number

Returns length of the vector.

Vec4.length2()
Return type:

Number

Returns squared length of the vector.

Vec4.mul(v)
Arguments:
Return type:

whale-core.Vec4

Vec4.mul(n)
Arguments:
  • n (Number)

Return type:

whale-core.Vec4

Vec4.neg()
Return type:

whale-core.Vec4

Vec4.normalize()
Return type:

whale-core.Vec4

Vec4.reflect(normal)
Arguments:
Return type:

whale-core.Vec4

Vec4.sub(v)
Arguments:
Return type:

whale-core.Vec4

Vec4.sub(n)
Arguments:
  • n (Number)

Return type:

whale-core.Vec4

class whale-core.VertexAttr(name, type)
Arguments:

Represent an OpenGL vertex attribute.

VertexAttr.Type
Type:

Object

VertexAttr.Type.FLOAT
VertexAttr.Type.VEC2
VertexAttr.Type.VEC3
VertexAttr.Type.VEC4
VertexAttr.Type.MAT2
VertexAttr.Type.MAT3
VertexAttr.Type.MAT4
class whale-core.VertexAttrList()

Represents an OpenGL vertex attribute list.

VertexAttrList.push(vertexAttr)
Arguments:
class whale-core.Window(name, position, size, options)
Arguments:

Represents a SDL window.

Window.redraw()
Window.relativeMouseMode(enabled)
Arguments:
  • enabled (Boolean)

Window.title
Type:

String

Window.size
Type:

whale-core.IVec2

Window.Options
Type:

Object

Window.Options.FULLSCREEN
Window.Options.OPENGL
Window.Options.SHOWN
Window.Options.HIDDEN
Window.Options.BORDERLESS
Window.Options.RESIZABLE
Window.Options.MINIMIZED
Window.Options.MAXIMIZED
Window.Options.INPUT_GRABBED
Window.Options.INPUT_FOCUS
Window.Options.MOUSE_FOCUS
Window.Options.MOUSE_CAPTURE
whale-core.ceil(n)
Arguments:
  • n (Number)

Return type:

Number

whale-core.ceil(v)
Arguments:
Return type:

whale-core.Vec1

whale-core.ceil(v)
Arguments:
Return type:

whale-core.Vec2

whale-core.ceil(v)
Arguments:
Return type:

whale-core.Vec3

whale-core.ceil(v)
Arguments:
Return type:

whale-core.Vec4

Computes the least integer value not less than the parameter.

whale-core.clamp(x, min, max)
Arguments:
  • x (Number)

  • min (Number)

  • max (Number)

Return type:

Number

whale-core.clamp(x, min, max)
Arguments:
Return type:

whale-core.Vec1

whale-core.clamp(x, min, max)
Arguments:
Return type:

whale-core.Vec2

whale-core.clamp(x, min, max)
Arguments:
Return type:

whale-core.Vec3

whale-core.clamp(x, min, max)
Arguments:
Return type:

whale-core.Vec4

Clamps a value to a specified range.

For vectors, it returns a vector with each element being clamped to a range specified by corresponding input elements.

whale-core.clone(obj)
Arguments:
  • obj (Object)

Return type:

Object

Clones a native WhaleJS object.

whale-core.delay(time)
Arguments:
  • time (Number) – Time in ms.

whale-core.finalize(obj)
Arguments:
  • obj (Object)

Finalizes a native WhaleJS object. It can be used to force early release of resources (such as files or OpenGL objects), before their handle objects get destroyed by garbage collector.

Note

Accessing an object after manual finalization is prohibited.

whale-core.inverse(m)
Arguments:
Return type:

whale-core.Mat2

whale-core.inverse(m)
Arguments:
Return type:

whale-core.Mat3

whale-core.inverse(m)
Arguments:
Return type:

whale-core.Mat4

Calculates inverse matrix.

whale-core.loadImage(buffer)
Arguments:
Return type:

whale-core.Image

Loads an image from a buffer. Automatically detects image format.

Currently, only PNG files are supported.

whale-core.loadJPEG(buffer)
Arguments:
Return type:

whale-core.Image

Loads a JPEG image from a buffer.

Currently unsupported (it will always fail with an error).

whale-core.loadPNG(buffer)
Arguments:
Return type:

whale-core.Image

Loads a PNG image from a buffer.

whale-core.print(text)
Arguments:
  • text (String)

Prints text to stdout.

whale-core.print_error(text)
Arguments:
  • text (String)

Prints text to stderr.

whale-core.max(a, b)
Arguments:
  • a (Number)

  • b (Number)

Return type:

Number

whale-core.max(a, b)
Arguments:
Return type:

whale-core.Vec1

whale-core.max(a, b)
Arguments:
Return type:

whale-core.Vec2

whale-core.max(a, b)
Arguments:
Return type:

whale-core.Vec3

whale-core.max(a, b)
Arguments:
Return type:

whale-core.Vec4

Returns the larger one of two values.

For vectors, it returns a vector with each element being the larger value of corresponding input elements.

whale-core.min(a, b)
Arguments:
  • a (Number)

  • b (Number)

Return type:

Number

whale-core.min(a, b)
Arguments:
Return type:

whale-core.Vec1

whale-core.min(a, b)
Arguments:
Return type:

whale-core.Vec2

whale-core.min(a, b)
Arguments:
Return type:

whale-core.Vec3

whale-core.min(a, b)
Arguments:
Return type:

whale-core.Vec4

Returns the smaller one of two values.

For vectors, it returns a vector with each element being smaller value of corresponding input elements.

whale-core.ortho(left, right, bottom, top, near, far)
Arguments:
  • left (Number)

  • right (Number)

  • bottom (Number)

  • top (Number)

  • near (Number)

  • far (Number)

Return type:

whale-core.Mat4

Constructs an orthogonal projection matrix.

whale-core.perspective(fovy, aspect, near, far)
Arguments:
  • fovy (Number)

  • aspect (Number)

  • near (Number)

  • far (Number)

Return type:

whale-core.Mat4

Constructs a perspective projection matrix.

whale-core.pollEvent()
Return type:

whale-core.Event

Polls a window event.

whale-core.rotate(angle)
Arguments:
  • angle (Number) – Angle in radians.

Return type:

whale-core.Mat3

Constructs a 2D rotation matrix.

whale-core.rotate(axis, angle)
Arguments:
Return type:

whale-core.Mat4

Constructs a 3D rotation matrix.

whale-core.scale(factor)
Arguments:
Return type:

whale-core.Mat3

Constructs a 2D scaling matrix.

whale-core.ticks()
Return type:

Number

Returns the number of milliseconds that have elapsed since the SDL library initialization.

whale-core.translate(offset)
Arguments:
Return type:

whale-core.Mat3

Constructs a 2D translation matrix.

whale-core.translate(offset)
Arguments:
Return type:

whale-core.Mat4

Constructs a 3D translation matrix.

whale-core.fs
Type:

whale-core.LocalFileSystem

Object representing local file system.