Skip to main content

Quad

Represents a region/part of an image.

Which can be drawn. In this way, one large images atlas (sheet) can be loaded, and then split up into sub-images.

Creation

quad

Creates a new quad.

createdQuad = quad(x, y, width, height, sourceWidth, sourceHeight)
ParameterTypeDefaultNote
xnumber⚠️ requiredof the region you wish to crop.
ynumber⚠️ requiredof the region you wish to crop.
widthnumber⚠️ requiredof the region you wish to crop.
heightnumber⚠️ requiredof the region you wish to crop.
sourceWidthnumber⚠️ requiredof the source image.
sourceHeightnumber⚠️ requiredof the source image.
ReturnTypeNote
createdQuadQuad

Obtained through a shorthand

Various shorthands are available to save the need of passing sourceWidth and sourceHeight manually:

Usage

Methods

caution

Object methods should be called using the : operator. Which passes the object itself as a parameter before all the other specified parameters. That is necessary for object methods to work efficiently.

For example to call the method shutdown on the object myComputer the both ways would work:

myComputer:shutdown()

quad:getTextureDimensions

Get the source image dimensions initially specified during creation.

sourceWidth, sourceHeight = quad:getTextureDimensions()
ReturnTypeNote
sourceWidthnumberin pixels.
sourceHeightnumberin pixels.

quad:getViewport

Get the viewport (region) specified in this quad.

x, y, width, height = quad:getViewport()
ReturnTypeNote
xnumber
ynumber
widthnumber
heightnumber

quad:setViewport

Set the viewport (region) specified in this quad.

quad:setViewport(x, y, width, height)
ParameterTypeDefaultNote
xnumber⚠️ required
ynumber⚠️ required
widthnumber⚠️ required
heightnumber⚠️ required

quad:type

Get the type of the object as a string.

danger

This method most likely will be removed in a future version.

objectType = quad:type()
ReturnTypeNote
objectTypestringQuad

quad:typeOf

Checks whether an object is of a certain type. If the object has the type with the specified name in its hierarchy, this function will return true.

danger

This method most likely will be removed in a future version.

For GPUQuad, it returns true for the following types:

isIt = quad:typeOf(type)
ParameterTypeDefaultNote
typestring⚠️ required
ReturnTypeNote
isItboolean'Object', 'Quad' would give true.