|
LifeLua 21-08-2025
Documentation for LifeLua, a Lua interpreter for the PS Vita
|
Loading, creating, drawing and saving images. More...
Every function that takes an image as its first parameter can also be called as a method:
Images are freed automatically when they are no longer used (garbage collected).
All the rotating functions take the angle in radians (use math.rad(degrees) to convert) and use the given position as the center of the image.
Functions | |
| image | image.load (string path) |
| image | image.new (number width, number height, color color) |
| image | image.screen () |
| nil | image.display (image image, number x, number y, color tint) |
| nil | image.scaledisplay (image image, number x, number y, number scale_x, number scale_y, color tint) |
| nil | image.rotatedisplay (image image, number x, number y, number angle, color tint) |
| nil | image.scalerotatedisplay (image image, number x, number y, number scale_x, number scale_y, number angle, color tint) |
| nil | image.partdisplay (image image, number x, number y, number tex_x, number tex_y, number tex_w, number tex_h, color tint) |
| nil | image.scalepartdisplay (image image, number x, number y, number tex_x, number tex_y, number tex_w, number tex_h, number scale_x, number scale_y, color tint) |
| nil | image.scalerotatepartdisplay (image image, number x, number y, number tex_x, number tex_y, number tex_w, number tex_h, number scale_x, number scale_y, number angle, color tint) |
| number | image.width (image image) |
| number | image.height (image image) |
| color | image.pixel (image image, number x, number y, color color) |
| nil | image.grayscale (image image) |
| nil | image.invert (image image) |
| nil | image.filter (image image, SceGxmTextureFilter min, SceGxmTextureFilter mag) |
| SceGxmTextureFilter | image.min (image image) |
| SceGxmTextureFilter | image.mag (image image) |
| nil | image.save (image image, string path, string type, number quality) |
| string | image.qrscan (image image, number index) |
| image | image.qr (table parameters) |
Texture filters | |
Used with image.filter(), image.min() and image.mag() | |
| SceGxmTextureFilter | SCE_GXM_TEXTURE_FILTER_POINT |
| Nearest pixel, keeps the image sharp/pixelated when scaled (good for pixel art) | |
| SceGxmTextureFilter | SCE_GXM_TEXTURE_FILTER_LINEAR |
| Smooths the image when scaled. | |
| SceGxmTextureFilter | SCE_GXM_TEXTURE_FILTER_MIPMAP_LINEAR |
| Linear filtering with mipmaps. | |
| SceGxmTextureFilter | SCE_GXM_TEXTURE_FILTER_MIPMAP_POINT |
| Point filtering with mipmaps. | |
QR code error correction levels | |
Used in the | |
| qrcodegen_Ecc | qrcodegen_Ecc_LOW |
| About 7% of the QR code can be damaged. | |
| qrcodegen_Ecc | qrcodegen_Ecc_MEDIUM |
| About 15% of the QR code can be damaged (default) | |
| qrcodegen_Ecc | qrcodegen_Ecc_QUARTILE |
| About 25% of the QR code can be damaged. | |
| qrcodegen_Ecc | qrcodegen_Ecc_HIGH |
| About 30% of the QR code can be damaged. | |
QR code masks | |
Used in the | |
| qrcodegen_Mask | qrcodegen_Mask_AUTO |
| Picks the best mask automatically (default) | |
| qrcodegen_Mask | qrcodegen_Mask_0 |
| Mask pattern 0. | |
| qrcodegen_Mask | qrcodegen_Mask_1 |
| Mask pattern 1. | |
| qrcodegen_Mask | qrcodegen_Mask_2 |
| Mask pattern 2. | |
| qrcodegen_Mask | qrcodegen_Mask_3 |
| Mask pattern 3. | |
| qrcodegen_Mask | qrcodegen_Mask_4 |
| Mask pattern 4. | |
| qrcodegen_Mask | qrcodegen_Mask_5 |
| Mask pattern 5. | |
| qrcodegen_Mask | qrcodegen_Mask_6 |
| Mask pattern 6. | |
| qrcodegen_Mask | qrcodegen_Mask_7 |
| Mask pattern 7. | |
QR code versions | |
Used in the | |
| number | qrcodegen_VERSION_MIN |
| Smallest QR code version (1) | |
| number | qrcodegen_VERSION_MAX |
| Biggest QR code version (40) | |
| nil image.display | ( | image | image, |
| number | x, | ||
| number | y, | ||
| color | tint ) |
Draws an image
Method form: img:display(x, y, tint)
| image | The image |
| x | Left position |
| y | Top position |
| tint | Color multiplied with the image, e.g. a half transparent white makes the image half transparent (optional) |
| nil image.filter | ( | image | image, |
| SceGxmTextureFilter | min, | ||
| SceGxmTextureFilter | mag ) |
Sets how an image is smoothed when it's drawn scaled
Method form: img:filter(min, mag)
| image | The image |
| min | Filter used when the image is drawn smaller, one of the texture filter constants |
| mag | Filter used when the image is drawn bigger (optional, default: same as min) |
| nil image.grayscale | ( | image | image | ) |
Turns an image into black & white. This changes the image itself.
Method form: img:grayscale()
| image | The image |
| number image.height | ( | image | image | ) |
Gets the height of an image
Method form: img:height()
| image | The image |
| nil image.invert | ( | image | image | ) |
Inverts the colors of an image (like a photo negative). This changes the image itself, the alpha stays the same.
Method form: img:invert()
| image | The image |
| image image.load | ( | string | path | ) |
Loads an image file. Supported formats: .PNG, .JPG/.JPEG, .BMP, .TGA, .PSD, .HDR, .PIC, .PPM/.PGM and .SVG.
| path | Path to the image (e.g. "app0:bg.png") |
nil if the file doesn't exist or its format isn't supported | SceGxmTextureFilter image.mag | ( | image | image | ) |
Gets the filter used when the image is drawn bigger
Method form: img:mag()
| image | The image |
| SceGxmTextureFilter image.min | ( | image | image | ) |
Gets the filter used when the image is drawn smaller
Method form: img:min()
| image | The image |
| image image.new | ( | number | width, |
| number | height, | ||
| color | color ) |
Creates a new, empty image
| width | Width in pixels |
| height | Height in pixels |
| color | Color to fill the image with (optional, the image is fully transparent if omitted) |
| nil image.partdisplay | ( | image | image, |
| number | x, | ||
| number | y, | ||
| number | tex_x, | ||
| number | tex_y, | ||
| number | tex_w, | ||
| number | tex_h, | ||
| color | tint ) |
Draws only a part of an image, useful for sprite sheets
Method form: img:partdisplay(x, y, tex_x, tex_y, tex_w, tex_h, tint)
| image | The image |
| x | Left position on the screen |
| y | Top position on the screen |
| tex_x | Left of the part inside the image |
| tex_y | Top of the part inside the image |
| tex_w | Width of the part |
| tex_h | Height of the part |
| tint | Color multiplied with the image (optional) |
| color image.pixel | ( | image | image, |
| number | x, | ||
| number | y, | ||
| color | color ) |
Gets or sets the color of one pixel of an image
Method form: img:pixel(x, y) / img:pixel(x, y, color)
| image | The image |
| x | X of the pixel, from 0 to width - 1 |
| y | Y of the pixel, from 0 to height - 1 |
| color | New color of the pixel (optional) |
color is omitted, otherwise nothing | image image.qr | ( | table | parameters | ) |
Generates a QR code image
| parameters | A table with these fields (only text is required):
|
| string image.qrscan | ( | image | image, |
| number | index ) |
Looks for a QR code in an image and reads it
Method form: img:qrscan(index)
| image | The image |
| index | Which QR code to read if there are several, starting at 0 (optional, default: 0) |
nil if no readable QR code was found | nil image.rotatedisplay | ( | image | image, |
| number | x, | ||
| number | y, | ||
| number | angle, | ||
| color | tint ) |
Draws a rotated image
Method form: img:rotatedisplay(x, y, angle, tint)
| image | The image |
| x | X position of the image's center |
| y | Y position of the image's center |
| angle | Rotation in radians |
| tint | Color multiplied with the image (optional) |
| nil image.save | ( | image | image, |
| string | path, | ||
| string | type, | ||
| number | quality ) |
Saves an image to a file
Method form: img:save(path, type, quality)
| image | The image |
| path | Where to save it (e.g. "ux0:data/picture.png") |
| type | File type (optional, default: "png"), one of:
|
| quality | JPEG quality from 1 to 100, only used for "jpg"/"jpeg" (optional, default: 100) |
| nil image.scaledisplay | ( | image | image, |
| number | x, | ||
| number | y, | ||
| number | scale_x, | ||
| number | scale_y, | ||
| color | tint ) |
Draws a scaled image
Method form: img:scaledisplay(x, y, scale_x, scale_y, tint)
| image | The image |
| x | Left position |
| y | Top position |
| scale_x | Horizontal scale, 1 is the original size, 2 is twice as wide, -1 flips the image |
| scale_y | Vertical scale, 1 is the original size, 2 is twice as tall, -1 flips the image |
| tint | Color multiplied with the image (optional) |
| nil image.scalepartdisplay | ( | image | image, |
| number | x, | ||
| number | y, | ||
| number | tex_x, | ||
| number | tex_y, | ||
| number | tex_w, | ||
| number | tex_h, | ||
| number | scale_x, | ||
| number | scale_y, | ||
| color | tint ) |
Draws a scaled part of an image
Method form: img:scalepartdisplay(x, y, tex_x, tex_y, tex_w, tex_h, scale_x, scale_y, tint)
| image | The image |
| x | Left position on the screen |
| y | Top position on the screen |
| tex_x | Left of the part inside the image |
| tex_y | Top of the part inside the image |
| tex_w | Width of the part |
| tex_h | Height of the part |
| scale_x | Horizontal scale, 1 is the original size |
| scale_y | Vertical scale, 1 is the original size |
| tint | Color multiplied with the image (optional) |
| nil image.scalerotatedisplay | ( | image | image, |
| number | x, | ||
| number | y, | ||
| number | scale_x, | ||
| number | scale_y, | ||
| number | angle, | ||
| color | tint ) |
Draws a scaled and rotated image
Method form: img:scalerotatedisplay(x, y, scale_x, scale_y, angle, tint)
| image | The image |
| x | X position of the image's center |
| y | Y position of the image's center |
| scale_x | Horizontal scale, 1 is the original size |
| scale_y | Vertical scale, 1 is the original size |
| angle | Rotation in radians |
| tint | Color multiplied with the image (optional) |
| nil image.scalerotatepartdisplay | ( | image | image, |
| number | x, | ||
| number | y, | ||
| number | tex_x, | ||
| number | tex_y, | ||
| number | tex_w, | ||
| number | tex_h, | ||
| number | scale_x, | ||
| number | scale_y, | ||
| number | angle, | ||
| color | tint ) |
Draws a scaled and rotated part of an image
Method form: img:scalerotatepartdisplay(x, y, tex_x, tex_y, tex_w, tex_h, scale_x, scale_y, angle, tint)
| image | The image |
| x | X position of the part's center on the screen |
| y | Y position of the part's center on the screen |
| tex_x | Left of the part inside the image |
| tex_y | Top of the part inside the image |
| tex_w | Width of the part |
| tex_h | Height of the part |
| scale_x | Horizontal scale, 1 is the original size |
| scale_y | Vertical scale, 1 is the original size |
| angle | Rotation in radians |
| tint | Color multiplied with the image (optional) |
| image image.screen | ( | ) |
Takes a screenshot of the screen as an image (960 × 544)
| number image.width | ( | image | image | ) |
Gets the width of an image
Method form: img:width()
| image | The image |