GPU - Graphics Processing Unit
It's the strongest peripheral in LIKO-12, it's responsible for creating the window and doing all the drawing operations.
- Version: v1.0.0
- Available since: LIKO-12 v0.6.0
- Last updated in: LIKO-12 v0.8.0
Methods:
GPU._systemMessage
Shows a system message: A single line message at the bottom of the screen.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
GPU._systemMessage(msg, time, tColor, bgColor)
Arguments:
- <msg> (string): The message to show.
- [time] (number) (Default:
1
): How long the message to be shown, (in seconds). - [tColor] (number) (Default:
4
): The color of the text (0-15). - [bgColor] (number) (Default:
9
): The color of the background (0-15).
GPU.cam
Transforms the drawing operations.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
The transforming operations sums up, to reset check the fifth usage of this function.
Usages:
1. Translate drawing positions:
Shifts all drawing operations.
GPU.cam("translate", x, y)
Arguments:
"translate"
(string)- <x> (number): The translation relative to the x-axis.
- <y> (number): The translation relative to the y-axis.
2. Scale drawing operations:
Scales all the drawing operations.
GPU.cam("scale", sx, sy)
Arguments:
"scale"
(string)- <sx> (number): The scaling in the direction of the x-axis.
- <sy> (number): The scaling in the direction of the y-axis.
3. Rotate drawing operations:
GPU.cam("rotate", a)
Arguments:
"rotate"
(string)- <a> (number): The amount to rotate the coordinate system in radians.
4. Shear drawing operations:
GPU.cam("shear", x, y)
Arguments:
"shear"
(string)- <x> (number): The shear factor on the x-axis.
- <y> (number): The shear factor on the y-axis.
5. Reset all the tranformations:
Resets all the tranformations done back to their original state.
GPU.cam()
GPU.circle
Draws a circle on the screen.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
The arguments can be passed in a table.
GPU.circle(x, y, r, l, c, seg)
Arguments:
- <x> (number): The x coord of circle center.
- <y> (number): The y coord of circle center.
- <r> (number): The radius of circle.
- <l> (boolean): (false/nil) The circle will be filled, (true) The circle will have only lines (outline).
- <c> (number): The color of the circle (0-15), defaults to the active color.
- <seg> (number): The number of the segments used when drawing the circle.
GPU.clear
Clears the screen and fills it with a specific color, useful when clearing the screen for a new frame.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
GPU.clear(id)
Arguments:
- [id] (number) (Default:
0
): The ID of the color to fill the screen with, can be 0-15.
GPU.clearMatrixStack
Clears the matrix stack (By calling popMatrix()
).
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
GPU.clearMatrixStack()
GPU.clip
Sets the region that the GPU can draw on.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
Usages:
1. Enable clipping:
The arguments can be passed in a table.
GPU.clip(x, y, w, h)
Arguments:
- <x> (number): The top-left X coord of the clipping area.
- <y> (number): The top-left Y coord of the clipping area.
- <w> (number): The width of the clipping area.
- <h> (number): The height of the clipping area.
2. Disable clipping:
GPU.clip()
GPU.color
Set's the current active color.
Set's the current active color.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
Usages:
1. Set the current active color:
GPU.color(id)
Arguments:
- <id> (number): The new active color id (0-15).
2. Get the current active color:
id = GPU.color()
Returns:
- id (number): The current active color id (0-15).
GPU.colorPalette
Allows you to read and modify the real RGBA values of a color in the palette.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
Usages:
1. Read the RGB values of a color:
r, g, b = GPU.colorPalette(id)
Arguments:
- <id> (number): The color id.
Returns:
- r (number): The channel red value [0-225]
- g (number): The channel green value [0-225]
- b (number): The channel blue value [0-225]
2. Set the RGB values of a color:
GPU.colorPalette(id, r, g, b)
Arguments:
- <id> (number): The color id.
- <r> (number): The channel red value [0-225]
- <g> (number): The channel green value [0-225]
- <b> (number): The channel blue value [0-225]
3. Reset the palette colors to their defaults (PICO-8 Palette):
GPU.colorPalette()
GPU.cursor
Sets the current active mouse cursor, or creates a new one.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
Usages:
1. Set the current mouse cursor:
GPU.cursor(name, grap)
Arguments:
- <name> (string): The name of the cursor.
- [grap] (boolean) (Default:
false
): True -> Grap the cursor to the pixelated screen.
2. Get the current mouse cursor:
current = GPU.cursor()
Returns:
- current (string): The current active cursor name.
3. Create a new cursor:
GPU.cursor(imgdata, name, hx, hy)
Arguments:
- <imgdata> (GPU/imageData): The imagedata of the cursor.
- [name] (string) (Default:
"default"
): The name of the cursor. - [hx] (number) (Default:
0
): The X coord of the cursor hot position. - [hy] (number) (Default:
0
): The Y coord of the cursor hot position.
GPU.ellipse
Draws an ellipse on the screen.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
The arguments can be passed in a table
GPU.ellipse(x, y, rx, ry, l, r, seg)
Arguments:
- <x> (number): The x coord of ellipse center.
- <y> (number): The y coord of ellipse center.
- <rx> (number): The radius of the ellipse along the x-axis (half the ellipse's width).
- <ry> (number): The radius of the ellipse along the y-axis (half the ellipse's height).
- [l] (boolean) (Default:
false
): (false/nil) The ellipse will be filled, (true) The ellipse will have only lines (outline). - <r> (number): The color of the ellipse (0-15), defaults to the active color.
- <seg> (number): The number of the segments used when drawing the ellipse.
GPU.endGifRecording
End LIKO-12 screen Gif recording by code.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
GPU.endGifRecording()
GPU.flip
Waits till the screen is applied and shown to the user, helpful when doing some loading operations.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
GPU.flip()
GPU.fontHeight
Returns height of the font character in pixels.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
height = GPU.fontHeight()
Returns:
- height (number): The height of the font character.
GPU.fontSize
Returns size of the font character in pixels.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
height, width = GPU.fontSize()
Returns:
- height (number): The height of the font character.
- width (number): The width of the font character.
GPU.fontWidth
Returns width of the font character in pixels.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
width = GPU.fontWidth()
Returns:
- width (number): The width of the font character.
GPU.getLabelImage
Returns the imagedata object of LabelImage, which can be capture by pressing F6, It will automatically update to the latest capture.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
limg = GPU.getLabelImage()
Returns:
- limg (GPU/imageData): The imagedata object of the label.
GPU.getMPos
Gets position of the mouse.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
mx, my = GPU.getMPos()
Returns:
- mx (number): The x position of the mouse.
- my (number): The y position of the mouse.
GPU.image
Creats a new image that can be used for drawing.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
img = GPU.image(data)
Arguments:
- <data> (string): The image data, must be in Image format.
Returns:
- img (GPU/image): The created image object.
GPU.imagedata
Creates a new imagedata object, which can be used for images processing (Set pixels, Get Pixels, encode, export, etc...).
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
All transparent pixels and all colors that are not from the palette will be loaded as black!
imgdata = GPU.imagedata(data)
Arguments:
- <data> (string): The image data, (png binary string or in lk12 format)
Returns:
- imgdata (GPU/imageData): The created imagedata object.
GPU.isGifRecording
Tells if the GPU is recording the screen or not.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
recording = GPU.isGifRecording()
Returns:
- recording (boolean): Is the GPU recording the screen or not.
GPU.isMDown
Checks if a mouse button is down.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
bool = GPU.isMDown(button)
Arguments:
- <button> (number): The button to check, 1 for left mouse button, 2 for right mouse button, 3 for middle mouse button.
Returns:
- bool (boolean): True if mouse button is down, false if not.
GPU.line
Draws line(s) on the screen.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
GPU.line(x1, y1, x2, y2, ..., color)
Arguments:
- <x1> (number): The x position of the first end of the line.
- <y1> (number): The y position of the first end of the line.
- <x2> (number): The x position of the second end of the line.
- <y2> (number): The y position of the second end of the line.
- ... (number): Any other lines to draw at the same time.
- <color> (number): The color of the line(s) (0-15), defaults to the active color.
GPU.pal
Maps a color in the palette to another color.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
There are 2 palettes in LIKO-12: The Images palette which affects images only. And the Drawing palette which affects all other GPU functions.
Usages:
1. Reset the whole palette.
GPU.pal(A, B, palette)
Arguments:
- <A> (boolean, number): The color to replace, or false for all
- <B> (number): The color which will replace A
- <palette> (number, boolean): (0) will reset the color in the Drawing palette only, (1) will reset the color in the Images palette only, (nil/false) will reset the color in both palettes.
2. Reset a specific color to it's default.
GPU.pal(color, false, p)
Arguments:
- <color> (number): The color to reset to it's default.
- <false> (boolean): literal
- <p> (number, boolean): (0) will reset the color in the Drawing palette only, (1) will reset the color in the Images palette only, (nil/false) will reset the color in both palettes.
GPU.palt
Makes a specific color transparent or not, by default the color 0 is transparent.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
This only affects images.
Usages:
1. Make a specific color transparent or not.
GPU.palt(color, transparent)
Arguments:
- <color> (number): The color id (0-15).
- [transparent] (boolean) (Default:
nil
): (true) The color will be transparent, (false/nil) The color will be opaque.
2. Reset the colors to it's default.
GPU.palt()
GPU.pauseGifRecording
Pause LIKO-12 screen Gif recording by code.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
GPU.pauseGifRecording()
GPU.point
Draws point(s) on the screen.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
GPU.point(x, y, ..., color)
Arguments:
- <x> (number): The x position of the point.
- <y> (number): The y position of the point.
- ... (number): Any other points to draw at the same time.
- <color> (number): The color of the point(s) (0-15), defaults to the active color.
GPU.polygon
Draws a polygon on the screen.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
GPU.polygon(x1, y1, x2, y2, x3, y3, ..., color)
Arguments:
- <x1> (number): The x position of the first vertex of the polygon.
- <y1> (number): The y position of the first vertex of the polygon.
- <x2> (number): The x position of the second vertex of the polygon.
- <y2> (number): The y position of the second vertex of the polygon.
- <x3> (number): The x position of the third vertex of the polygon.
- <y3> (number): The y position of the third vertex of the polygon.
- ... (number): Any other vertices of the polygon.
- <color> (number): The color of the polygon (0-15), defaults to the active color.
GPU.popColor
Pops the last active color from the ColorStack.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
GPU.popColor()
GPU.popMatrix
Pops the last cam transformations from the MatrixStack.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
GPU.popMatrix()
GPU.popPalette
Pop the last color mapping and transparent colors list from the palettes stack.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
GPU.popPalette()
GPU.print
Prints text to the screen, uses the current active color.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
Usages:
1. Print at a specific position on the screen with wrapping mode
GPU.print(text, x, y, limit, align, r, sx, sy, ox, oy, kx, ky)
Arguments:
- <text> (string): The text to draw.
- <x> (number): The X coord to draw at.
- <y> (number): The y coord to draw at.
- <limit> (number): Wrap the line after this many horizontal pixels.
- [align] (string) (Default:
"left"
): The text alignment (can be "left", "center" and "right"). - [r] (number) (Default:
0
): Rotation (radians). - [sx] (number) (Default:
1
): Scale factor (x-axis). - [sy] (number) (Default:
sx
): Scale factor (y-axis). - [ox] (number) (Default:
0
): Origin offset (x-axis). - [oy] (number) (Default:
0
): Origin offset (y-axis). - [kx] (number) (Default:
0
): Shear factor (x-axis). - [ky] (number) (Default:
0
): Shear factor (y-axis).
2. Print at a specific position on the screen without wrapping.
GPU.print(text, x, y, false, false, r, sx, sy, ox, oy, kx, ky)
Arguments:
- <text> (string): The text to draw.
- <x> (number): The X coord to draw at.
- <y> (number): The y coord to draw at.
false
(boolean)false
(boolean)- [r] (number) (Default:
0
): Rotation (radians). - [sx] (number) (Default:
1
): Scale factor (x-axis). - [sy] (number) (Default:
sx
): Scale factor (y-axis). - [ox] (number) (Default:
0
): Origin offset (x-axis). - [oy] (number) (Default:
0
): Origin offset (y-axis). - [kx] (number) (Default:
0
): Shear factor (x-axis). - [ky] (number) (Default:
0
): Shear factor (y-axis).
3. Print in terminal grid way.
GPU.print(text)
Arguments:
- <text> (string): The text to draw.
4. Print in terminal grid without auto newline.
GPU.print(text, false)
Arguments:
- <text> (string): The text to draw.
false
(boolean)
5. Print in terminal grid directly without wrapping nor new line.
GPU.print(text, false, true)
Arguments:
- <text> (string): The text to draw.
false
(boolean)true
(boolean)
GPU.printBackspace
Deletes the last printed character via the 3rd and 4th variants of print()
, and it updates the cursor position.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
Usages:
1. Delete the last character:
GPU.printBackspace(c)
Arguments:
- <c> (number): The background color to fill the character with (-1,15), -1 means no background, defaults to the current print cursor background color.
2. Delete the last character without doing a carriage return if needed:
GPU.printBackspace(c, true)
Arguments:
- <c> (number): The background color to fill the character with (-1,15), -1 means no background, defaults to the current print cursor background color.
true
(boolean)
GPU.printCursor
Changes the print cursor position used by print()
in the grid variant.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
The positions are on a characters grid, the size of the grid can be requested from
termSize()
.
Usages:
1. Set cursor position:
GPU.printCursor(x, y, bgcolor)
Arguments:
- <x> (number): The X coord of the cursor in characters, defaults to the current X coord.
- <y> (number): The Y corrd of the cursor in characters, defaults to the current Y coord.
- <bgcolor> (number): The background color used when printing (-1,15), -1 means no background, defaults to the current background color.
2. Get cursor position
x, y, bgcolor = GPU.printCursor()
Returns:
- x (number): The current X coord of the cursor in characters.
- y (number): The current Y corrd of the cursor in characters.
- bgcolor (number): The current background color.
GPU.pushColor
Pushes the current active color to the ColorStack.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
GPU.pushColor()
GPU.pushMatrix
Pushes the current active camera transformations to the MatrixStack.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
GPU.pushMatrix()
GPU.pushPalette
Pushes the current color mapping and transparent colors list to the palettes stack.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
GPU.pushPalette()
GPU.quad
Creates a new quad.
Creates a new quad.
Quads can be used to select a part of an image to draw. In this way, one large images atlas (sheet) can be loaded, and then split up into sub-images.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
q = GPU.quad(x, y, w, h, sw, sh)
Arguments:
- <x> (number): The x coord of the quad's top-left corner.
- <y> (number): The y coord of the quad's top-left corner.
- <w> (number): The width of the quad.
- <h> (number): The height of the quad.
- <sw> (number): The width of the reference image.
- <sh> (number): The height of the reference image.
Returns:
- q (GPU/quad): The created quad
GPU.rect
Draws a rectangle on the screen.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
The arguments can be passed in a table
GPU.rect(x, y, w, h, l, c)
Arguments:
- <x> (number): The top-left x position of the rectangle.
- <y> (number): The top-left y position of the rectangle.
- <w> (number): The width of rectangle.
- <h> (number): The height of rectangle.
- [l] (boolean) (Default:
false
): (false/nil) The rectangle will be filled, (true) The rectangle will have only lines (border). - <c> (number): The color of the rectangle (0-15), defaults to the active color.
GPU.screenHeight
Returns the height of the screen.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
h = GPU.screenHeight()
Returns:
- h (number): The height of the screen (By default - 128)
GPU.screenSize
Returns the dimensions of the screen.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
w, h = GPU.screenSize()
Returns:
- w (number): The width of the screen (By default - 192)
- h (number): The height of the screen (By default - 128)
GPU.screenWidth
Returns the width of the screen.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
w = GPU.screenWidth()
Returns:
- w (number): The width of the screen (By default - 192)
GPU.screenshot
Takes a screenshot of the canvas (without the cursor), and returns its imagedata.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
imgdata = GPU.screenshot(x, y, w, h)
Arguments:
- [x] (number) (Default:
0
): The top-left X coord of the area to take the screenshot of. - [y] (number) (Default:
0
): The top-left Y coord of the area to take the screenshot of. - <w> (number): The width of the area to take the screenshot of.
- <h> (number): The height of the area to take the screenshot of.
Returns:
- imgdata (GPU/imageData): The created imagedata object.
GPU.startGifRecording
Start LIKO-12 screen Gif recording by code.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
GPU.startGifRecording()
GPU.termHeight
Returns height of the terminal in characters.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
Custom fonts can change the output values, don't assume anything.
h = GPU.termHeight()
Returns:
- h (number): The height of the terminal
GPU.termSize
Returns size of the terminal in characters.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
Custom fonts can change the output values, don't assume anything.
w, h = GPU.termSize()
Returns:
- w (number): The width of the terminal
- h (number): The height of the terminal
GPU.termWidth
Returns width of the terminal in characters.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
Custom fonts can change the output values, don't assume anything.
w = GPU.termWidth()
Returns:
- w (number): The width of the terminal
GPU.triangle
Draws a triangle on the screen.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
The arguments can be passed in a table
GPU.triangle(x1, y1, x2, y2, x3, y3, l, c)
Arguments:
- <x1> (number): The first x coordinate of triangle vector.
- <y1> (number): The first y coordinate of triangle vector.
- <x2> (number): The second x coordinate of triangle vector.
- <y2> (number): The second y coordinate of triangle vector.
- <x3> (number): The third x coordinate of triangle vector.
- <y3> (number): The third y coordinate of triangle vector.
- [l] (boolean) (Default:
false
): (false/nil) The triangle will be filled, (true) The triangle will have only lines (outline). - <c> (number): The color of triangle (0-15), defaults to the active color.
GPU.wrapText
Gets formatting information for text, given a wrap limit.
Gets formatting information for text, given a wrap limit.
This function accounts for newlines correctly (i.e. '\n').
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
width, wrappedText = GPU.wrapText(text, wraplimit)
Arguments:
- <text> (string): The text that will be wrapped.
- <wraplimit> (number): The maximum width in pixels of each line that text is allowed before wrapping.
Returns:
- width (string): The maximum width of the wrapped text.
- wrappedText (table): A sequence containing each line of text that was wrapped.
Events:
Please note that the example functions won't be called automatically, there must be some kind of an events handler for CPU.pullEvent, check if the LIKO-12 OS you're using has one.
filedropped
Triggered when a file is dropped into LIKO-12's window.
- Available since: GPU: v1.0.0, LIKO-12: v0.7.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.7.0
function _filedropped(filename, data)
--Content run when the event is triggered
end
Arguments:
- filename (string): The filename of the dropped file.
- data (string): The content of the dropped file.
mousemoved
Triggered when the mouse is moved, or if a screen touch was moved.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
function _mousemoved(x, y, dx, dy, istouch)
--Content run when the event is triggered
end
Arguments:
- x (number): Mouse x position, in pixels.
- y (number): Mouse y position, in pixels.
- dx (number): The amount moved along the x-axis since the last time mousemoved was triggered.
- dy (number): The amount moved along the y-axis since the last time mousemoved was triggered.
- istouch (boolean): True if the mouse move originated from a touchscreen touch-move.
mousepressed
Triggered when a mouse button is pressed, or if the screen was touched.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
function _mousepressed(x, y, button, istouch)
--Content run when the event is triggered
end
Arguments:
- x (number): Mouse x position, in pixels.
- y (number): Mouse y position, in pixels.
- button (number): The button index that was pressed. 1 is the primary mouse button, 2 is the secondary mouse button and 3 is the middle button. Further buttons are mouse dependent.
- istouch (boolean): True if the mouse button press originated from a touchscreen touch-press.
mousereleased
Triggered when a mouse button is released, or if the screen was no longer touched.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
function _mousereleased(x, y, button, istouch)
--Content run when the event is triggered
end
Arguments:
- x (number): Mouse x position, in pixels.
- y (number): Mouse y position, in pixels.
- button (number): The button index that was released. 1 is the primary mouse button, 2 is the secondary mouse button and 3 is the middle button. Further buttons are mouse dependent.
- istouch (boolean): True if the mouse button release originated from a touchscreen touch-release.
touchmoved
Triggered when a touch press moves inside the touchscreen.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
The identifier is only guaranteed to be unique for the specific touch press until touchreleased is triggered with that identifier, at which point it may be reused for new touch presses.
function _touchmoved(id, x, y, dx, dy, pressure)
--Content run when the event is triggered
end
Arguments:
- id (userdata): The identifier for the touch press.
- x (number): The x-axis position of the touch press inside the window, in pixels.
- y (number): The y-axis position of the touch press inside the window, in pixels.
- dx (number): The x-axis movement of the touch press inside the window, in pixels.
- dy (number): The y-axis movement of the touch press inside the window, in pixels.
- pressure (number): The amount of pressure being applied. Most touch screens aren't pressure sensitive, in which case the pressure will be 1.
touchpressed
Triggered when the touchscreen is touched.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
The identifier is only guaranteed to be unique for the specific touch press until touchreleased is triggered with that identifier, at which point it may be reused for new touch presses.
function _touchpressed(id, x, y, dx, dy, pressure)
--Content run when the event is triggered
end
Arguments:
- id (userdata): The identifier for the touch press.
- x (number): The x-axis position of the touch press inside the window, in pixels.
- y (number): The y-axis position of the touch press inside the window, in pixels.
- dx (number): The x-axis movement of the touch press inside the window, in pixels. This should always be zero.
- dy (number): The y-axis movement of the touch press inside the window, in pixels. This should always be zero.
- pressure (number): The amount of pressure being applied. Most touch screens aren't pressure sensitive, in which case the pressure will be 1.
touchreleased
Triggered when the touchscreen stops being touched.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
The identifier is only guaranteed to be unique for the specific touch press until touchreleased is triggered with that identifier, at which point it may be reused for new touch presses.
function _touchreleased(id, x, y, dx, dy, pressure)
--Content run when the event is triggered
end
Arguments:
- id (userdata): The identifier for the touch press.
- x (number): The x-axis position of the touch press inside the window, in pixels.
- y (number): The y-axis position of the touch press inside the window, in pixels.
- dx (number): The x-axis movement of the touch press inside the window, in pixels.
- dy (number): The y-axis movement of the touch press inside the window, in pixels.
- pressure (number): The amount of pressure being applied. Most touch screens aren't pressure sensitive, in which case the pressure will be 1.
wheelmoved
Triggered when the mouse wheel is moved.
- Available since: GPU: v1.0.0, LIKO-12: v0.6.0
- Last updated in: GPU: v1.0.0, LIKO-12: v0.6.0
function _wheelmoved(x, y)
--Content run when the event is triggered
end
Arguments:
- x (number): Amount of horizontal mouse wheel movement. Positive values indicate movement to the right.
- y (number): Amount of vertical mouse wheel movement. Positive values indicate upward movement.
Objects:
- fontData - fontData, modifiable pixel data, not drawable, convert to an font to print with.
- image - Drawable Image, not modifiable, convert to imageData to modify.
- imageData - ImageData, modifiable pixel data, not drawable, convert to an image to draw.
- quad - Quad, a region from an image, used when drawing an image to only draw that section.
- spriteBatch - Spritebatch, draw multiple parts of an image at once instantly, useful for maps.