Lua Player Plus Vita
Documentation of lpp-vita
Graphics

Module that handles 2D rendering. More...

Enumerations

enum  ImageFilter { FILTER_POINT , FILTER_LINEAR }
 Image filters to use with Graphics.setImageFilters. More...
 

Functions

void Graphics::initBlend (void)
 Initialize drawing phase. More...
 
void Graphics::termBlend (void)
 Terminate drawing phase. More...
 
void Graphics::debugPrint (number x, number y, string text, int color)
 Print a text on screen using system font. More...
 
void Graphics::drawPixel (number x, number y, int color, int image)
 Draw a pixel. More...
 
int Graphics::getPixel (int x, int y, int img)
 Get a pixel color from a loaded image. More...
 
void Graphics::drawLine (number x1, number x2, number y1, number y2, int color)
 Draw a line. More...
 
void Graphics::fillRect (number x1, number x2, number y1, number y2, int color)
 Draw a rectangle. More...
 
void Graphics::fillEmptyRect (number x1, number x2, number y1, number y2, int color)
 Draw an empty rectangle. More...
 
void Graphics::fillCircle (number x, number y, number rad, int color)
 Draw a circle. More...
 
int Graphics::createImage (int width, int height, int color)
 Create an empty image. More...
 
int Graphics::loadImage (string filename)
 Load a .png/.jpg/.bmp image. More...
 
void Graphics::saveImage (int img, string filename, ImgFmt format)
 Save a loaded image to a .png/.bmp image. More...
 
void Graphics::loadImageAsync (string filename)
 Load a .png/.jpg/.bmp image (asynchronous). More...
 
int Graphics::loadAnimatedImage (string filename)
 Load a .gif animated image. More...
 
int Graphics::getImageFramesNum (int img)
 Gets the number of frames of a loaded animated image. More...
 
void Graphics::setImageFrame (int img, int frame)
 Set current active frame for a loaded animated image. More...
 
void Graphics::freeImage (int img)
 Free a loaded image. More...
 
void Graphics::setImageFilters (int img, ImageFilter min_filter, ImageFilter mag_filter)
 Set filters to use for a given image. More...
 
int Graphics::getImageWidth (int img)
 Get an image width. More...
 
int Graphics::getImageHeight (int img)
 Get an image height. More...
 
void Graphics::drawImage (number x, number y, int img, int color)
 Draw an image. More...
 
void Graphics::drawRotateImage (number x, number y, int img, number rad, int color)
 Draw a rotated image. More...
 
void Graphics::drawScaleImage (number x, number y, int img, number x_scale, number y_scale, int color)
 Draw a scaled image. More...
 
void Graphics::drawPartialImage (number x, number y, int img, int x_start, int y_start, number width, number height, int color)
 Draw a part of an image. More...
 
void Graphics::drawImageExtended (number x, number y, int img, int x_start, int y_start, number width, number height, number rad, number x_scale, number y_scale, int color)
 Draw an image with several effects. More...
 
void Graphics::initRescaler (int x, int y, number x_scale, number y_scale)
 Initialize a rescaler. More...
 
void Graphics::termRescaler (void)
 Terminate a rescaler. More...
 

Detailed Description

Module that handles 2D rendering.

Enumeration Type Documentation

◆ ImageFilter

Image filters to use with Graphics.setImageFilters.

Enumerator
FILTER_POINT 

Point filter.

FILTER_LINEAR 

Linear filter.

Function Documentation

◆ initBlend()

void Graphics::initBlend ( void  )

Initialize drawing phase.

Usage example:
Definition: luaGraphics.cpp:15
void initBlend(void)
Initialize drawing phase.

◆ termBlend()

void Graphics::termBlend ( void  )

Terminate drawing phase.

Usage example:
void termBlend(void)
Terminate drawing phase.

◆ debugPrint()

void Graphics::debugPrint ( number  x,
number  y,
string  text,
int  color 
)

Print a text on screen using system font.

Usage example:
Graphics.debugPrint(10, 10, "Hello World", Color.new(255, 255, 255))
Definition: luaColor.cpp:6
int new(int r, int g, int b, int a)
Create a new color.
void debugPrint(number x, number y, string text, int color)
Print a text on screen using system font.
Parameters
x- X coordinate of the text position in pixels.
y- Y coordinate of the text position in pixels.
text- Text to print.
color- A valid color (See Color).

◆ drawPixel()

void Graphics::drawPixel ( number  x,
number  y,
int  color,
int  image 
)

Draw a pixel.

Usage example:
Graphics.drawPixel(5, 5, Color.new(15, 255, 200))
void drawPixel(number x, number y, int color, int image)
Draw a pixel.
Parameters
x- X coordinate of the pixel position in pixels.
y- Y coordinate of the pixel position in pixels.
color- A valid color (See Color).
image- Image to draw on (optional).
Note
If image is not provided, pixel will be drawn on screen.

◆ getPixel()

int Graphics::getPixel ( int  x,
int  y,
int  img 
)

Get a pixel color from a loaded image.

Usage example:
pixel_color = Graphics.getPixel(5, 25, img)
int getPixel(int x, int y, int img)
Get a pixel color from a loaded image.
Parameters
x- X coordinate of the pixel.
y- Y coordinate of the pixel.
img- A valid image ID.
Returns
The pixel color value (See Color).

◆ drawLine()

void Graphics::drawLine ( number  x1,
number  x2,
number  y1,
number  y2,
int  color 
)

Draw a line.

Usage example:
Graphics.drawLine(10, 25, 100, 250, Color.new(25, 200, 120))
void drawLine(number x1, number x2, number y1, number y2, int color)
Draw a line.
Parameters
x1- Starting X coordinate of the line in pixels.
x2- Ending X coordinate of the line in pixels.
y1- Starting Y coordinate of the line in pixels.
y2- Ending Y coordinate of the line in pixels.
color- A valid color (See Color).

◆ fillRect()

void Graphics::fillRect ( number  x1,
number  x2,
number  y1,
number  y2,
int  color 
)

Draw a rectangle.

Usage example:
Graphics.fillRect(10, 25, 100, 250, Color.new(25, 200, 120))
void fillRect(number x1, number x2, number y1, number y2, int color)
Draw a rectangle.
Parameters
x1- Starting X coordinate of the rectangle in pixels.
x2- Ending X coordinate of the rectangle in pixels.
y1- Starting Y coordinate of the rectangle in pixels.
y2- Ending Y coordinate of the rectangle in pixels.
color- A valid color (See Color).

◆ fillEmptyRect()

void Graphics::fillEmptyRect ( number  x1,
number  x2,
number  y1,
number  y2,
int  color 
)

Draw an empty rectangle.

Usage example:
Graphics.fillEmptyRect(10, 25, 100, 250, Color.new(25, 200, 120))
void fillEmptyRect(number x1, number x2, number y1, number y2, int color)
Draw an empty rectangle.
Parameters
x1- Starting X coordinate of the rectangle in pixels.
x2- Ending X coordinate of the rectangle in pixels.
y1- Starting Y coordinate of the rectangle in pixels.
y2- Ending Y coordinate of the rectangle in pixels.
color- A valid color (See Color).

◆ fillCircle()

void Graphics::fillCircle ( number  x,
number  y,
number  rad,
int  color 
)

Draw a circle.

Usage example:
Graphics.fillCircle(10, 25, 1.0, Color.new(25, 200, 120))
void fillCircle(number x, number y, number rad, int color)
Draw a circle.
Parameters
x- X coordinate of the circle in pixels.
y- Y coordinate of the circle in pixels.
rad- Radius size of the circle.
color- A valid color (See Color).

◆ createImage()

int Graphics::createImage ( int  width,
int  height,
int  color 
)

Create an empty image.

Usage example:
img = Graphics.createImage(Color.new(25, 200, 120))
int createImage(int width, int height, int color)
Create an empty image.
Parameters
width- Image width.
height- Image height.
color- A valid color (See Color) (optional).
Returns
A valid image ID.

◆ loadImage()

int Graphics::loadImage ( string  filename)

Load a .png/.jpg/.bmp image.

Usage example:
img = Graphics.loadImage("app0:/image.jpg")
int loadImage(string filename)
Load a .png/.jpg/.bmp image.
Parameters
filename- Name of the file to open.
Returns
A valid image ID.

◆ saveImage()

void Graphics::saveImage ( int  img,
string  filename,
ImgFmt  format 
)

Save a loaded image to a .png/.bmp image.

Usage example:
Graphics.saveImage(img, "ux0:/data/image.png", FORMAT_PNG)
void saveImage(int img, string filename, ImgFmt format)
Save a loaded image to a .png/.bmp image.
@ FORMAT_PNG
8bpp paletted PNG format.
Definition: luaSystem.cpp:44
Parameters
img- A valid image ID.
filename- The filename of the screenshot output.
format- The format to use for the output file (optional).
Note
FORMAT_JPG is not supported.

◆ loadImageAsync()

void Graphics::loadImageAsync ( string  filename)

Load a .png/.jpg/.bmp image (asynchronous).

Usage example:
Graphics.loadImageAsync("app0:/image.jpg")
while System.getAsyncState() == 0 do
end
Definition: luaSystem.cpp:78
void loadImageAsync(string filename)
Load a .png/.jpg/.bmp image (asynchronous).
int getAsyncState(void)
Get current state of an asynchronous task.
string getAsyncResult(void)
Get result from a finished asynchronous task.
Parameters
filename- Name of the file to open.

◆ loadAnimatedImage()

int Graphics::loadAnimatedImage ( string  filename)

Load a .gif animated image.

Usage example:
img = Graphics.loadAnimatedImage("app0:/image.gif")
int loadAnimatedImage(string filename)
Load a .gif animated image.
Parameters
filename- Name of the file to open.
Returns
A valid image ID.

◆ getImageFramesNum()

int Graphics::getImageFramesNum ( int  img)

Gets the number of frames of a loaded animated image.

Usage example:
img = Graphics.loadAnimatedImage("app0:/image.gif")
int getImageFramesNum(int img)
Gets the number of frames of a loaded animated image.
Parameters
img- A valid image ID.
Returns
The number of frames for the given image.

◆ setImageFrame()

void Graphics::setImageFrame ( int  img,
int  frame 
)

Set current active frame for a loaded animated image.

Usage example:
img = Graphics.loadAnimatedImage("app0:/image.gif")
void setImageFrame(int img, int frame)
Set current active frame for a loaded animated image.
Parameters
img- A valid image ID.
frame- The frame to set as active.

◆ freeImage()

void Graphics::freeImage ( int  img)

Free a loaded image.

Usage example:
void freeImage(int img)
Free a loaded image.
Parameters
img- A valid image ID.

◆ setImageFilters()

void Graphics::setImageFilters ( int  img,
ImageFilter  min_filter,
ImageFilter  mag_filter 
)

Set filters to use for a given image.

Usage example:
void setImageFilters(int img, ImageFilter min_filter, ImageFilter mag_filter)
Set filters to use for a given image.
@ FILTER_LINEAR
Linear filter.
Definition: luaGraphics.cpp:12
Parameters
img- A valid image ID.
min_filter- Min filter to use.
mag_filter- Mag filter to use.

◆ getImageWidth()

int Graphics::getImageWidth ( int  img)

Get an image width.

Usage example:
width = Graphics.getImageWidth(img)
int getImageWidth(int img)
Get an image width.
Parameters
img- A valid image ID.
Returns
The image width in pixels.

◆ getImageHeight()

int Graphics::getImageHeight ( int  img)

Get an image height.

Usage example:
height = Graphics.getImageHeight(img)
int getImageHeight(int img)
Get an image height.
Parameters
img- A valid image ID.
Returns
The image height in pixels.

◆ drawImage()

void Graphics::drawImage ( number  x,
number  y,
int  img,
int  color 
)

Draw an image.

Usage example:
Graphics.drawImage(50, 100, img)
void drawImage(number x, number y, int img, int color)
Draw an image.
Parameters
x- X coordinate of the image in pixels.
y- Y coordinate of the image in pixels.
img- A valid image ID.
color- Image tint color (See Color) (optional).

◆ drawRotateImage()

void Graphics::drawRotateImage ( number  x,
number  y,
int  img,
number  rad,
int  color 
)

Draw a rotated image.

Usage example:
Graphics.drawRotateImage(50, 100, img, 1.0)
void drawRotateImage(number x, number y, int img, number rad, int color)
Draw a rotated image.
Parameters
x- X coordinate of the image in pixels.
y- Y coordinate of the image in pixels.
img- A valid image ID.
rad- Rotation radius.
color- Image tint color (See Color) (optional).

◆ drawScaleImage()

void Graphics::drawScaleImage ( number  x,
number  y,
int  img,
number  x_scale,
number  y_scale,
int  color 
)

Draw a scaled image.

Usage example:
Graphics.drawScaleImage(50, 100, img, 0.5, 0.5)
void drawScaleImage(number x, number y, int img, number x_scale, number y_scale, int color)
Draw a scaled image.
Parameters
x- X coordinate of the image in pixels.
y- Y coordinate of the image in pixels.
img- A valid image ID.
x_scale- Scale value for X parameter.
y_scale- Scale value for Y parameter.
color- Image tint color (See Color) (optional).

◆ drawPartialImage()

void Graphics::drawPartialImage ( number  x,
number  y,
int  img,
int  x_start,
int  y_start,
number  width,
number  height,
int  color 
)

Draw a part of an image.

Usage example:
Graphics.drawPartialImage(50, 100, img, 20, 20, 100, 100)
void drawPartialImage(number x, number y, int img, int x_start, int y_start, number width, number height, int color)
Draw a part of an image.
Parameters
x- X coordinate of the image in pixels.
y- Y coordinate of the image in pixels.
img- A valid image ID.
x_start- Image X coordinate for the partial drawing.
y_start- Image Y coordinate for the partial drawing.
width- Partial drawing width.
height- Partial drawing height.
color- Image tint color (See Color) (optional).

◆ drawImageExtended()

void Graphics::drawImageExtended ( number  x,
number  y,
int  img,
int  x_start,
int  y_start,
number  width,
number  height,
number  rad,
number  x_scale,
number  y_scale,
int  color 
)

Draw an image with several effects.

Usage example:
Graphics.drawImageExtended(50, 100, img, 20, 20, 100, 100, 1.0, 0.5, 0.5)
void drawImageExtended(number x, number y, int img, int x_start, int y_start, number width, number height, number rad, number x_scale, number y_scale, int color)
Draw an image with several effects.
Parameters
x- X coordinate of the image in pixels.
y- Y coordinate of the image in pixels.
img- A valid image ID.
x_start- Image X coordinate for the partial drawing.
y_start- Image Y coordinate for the partial drawing.
width- Partial drawing width.
height- Partial drawing height.
rad- Rotation radius.
x_scale- Scale value for X parameter.
y_scale- Scale value for Y parameter.
color- Image tint color (See Color) (optional).

◆ initRescaler()

void Graphics::initRescaler ( int  x,
int  y,
number  x_scale,
number  y_scale 
)

Initialize a rescaler.

Usage example:
Graphics.initRescaler(0, 0, 2.0, 2.0)
void initRescaler(int x, int y, number x_scale, number y_scale)
Initialize a rescaler.
Parameters
x- X coordinate of the rescaler output.
y- Y coordinate of the rescaler output.
x_scale- Scale value for X parameter.
y_scale- Scale value for Y parameter.

◆ termRescaler()

void Graphics::termRescaler ( void  )

Terminate a rescaler.

Usage example:
void termRescaler(void)
Terminate a rescaler.