Module Drawing

Functions for drawing images and text.

See here for more information: link

Functions

drawImage (frame, x, y) Draws a frame.
drawImageRect (frame, x, y, w, h) Draws a frame into a specified rectangle.
drawLine (x0, y0, x1, y1[, width=1]) Draws a line.
drawNinePatch (frame, x, y, w, h[, sparse=false]) Draws a nine patch into a specified rectangle.
drawRect (x, y, w, h) Draws a filled rectangle.
drawText (text, x, y[, font=nil[, centerX=0[, centerY=0]]]) Draws a text.
drawTileImage (frame) Draws a tile frame on the currently set tile.
drawTriangle (x0, y0, x1, y1, x2, y2) Draws a triangle.
getAdditive () Returns the current additive factor for drawing.
getAlpha () Returns the current transparency for drawing.
getColor () Returns the current drawing color.
getImageHandle (frame) Returns the handle of an image/frame.
getImageSize (frame) Returns the size of an image/frame.
getScale () Returns the current scale factors set by setScale.
getSize () Returns the current screen size width, height in pixels.
getTextSize (text[, font=nil]) Queries the drawing size for a given text.
reset () Resets all drawing properties.
resetClipping () Resets clipping so that draw functions affect all pixels again.
setAdditive (additive) Sets the additive factor used for additive drawing.
setAlpha (alpha) Sets the transparency for drawing.
setClipping (x, y, w, h) Sets the clipping rect to a specified rectangle.
setColor (r, g, b) Sets the drawing color.
setScale (scaleX, scaleY) Sets the scale for drawing (absolute).
setTile (tileX, tileY[, offsetX=0[, offsetY=0[, localScaleX=1[, localScaleY=1]]]]) Sets the current drawing offset and scale to a certain tile on the map.


Functions

drawImage (frame, x, y)
Draws a frame.

Parameters:

  • frame integer or draft A frame or draft (that contains at least one frame).
  • x number The x coordinate for drawing.
  • y number The y coordinate for drawing.
drawImageRect (frame, x, y, w, h)
Draws a frame into a specified rectangle.

Parameters:

  • frame integer or draft A frame or draft (that contains at least one frame).
  • x number The x coordinate for drawing.
  • y number The y coordinate for drawing.
  • w number The width for drawing.
  • h number The height for drawing.
drawLine (x0, y0, x1, y1[, width=1])
Draws a line.

Parameters:

  • x0 number X component of the start point.
  • y0 number Y component of the start point.
  • x1 number X component of the end point.
  • y1 number Y component of the end point.
  • width number The width of the line. (default 1)
drawNinePatch (frame, x, y, w, h[, sparse=false])
Draws a nine patch into a specified rectangle. A nine patch is a set of 9 frames that are used to draw a rectangle with borders. All parts expect the corners are streched to match accordingly.

Parameters:

  • frame integer or draft The base frame of the nine patch.
  • x number The x coordinate for drawing.
  • y number The y coordinate for drawing.
  • w number The width for drawing.
  • h number The height for drawing.
  • sparse boolean If true the center frame will not be drawn. (default false)
drawRect (x, y, w, h)
Draws a filled rectangle.

Parameters:

  • x number The x coordinate for drawing.
  • y number The y coordinate for drawing.
  • w number The width for drawing.
  • h number The height for drawing.
drawText (text, x, y[, font=nil[, centerX=0[, centerY=0]]])
Draws a text.

Parameters:

  • text string The text to draw.
  • x number The x coordinate for drawing.
  • y number The y coordinate for drawing.
  • font font The font to use. (default nil)
  • centerX number The relative x center for the pivot point (usually ranges from 0 to 1; 0.5 would be the center of the text). (default 0)
  • centerY number The relative y center for the pivot point (usually ranges from 0 to 1; 0.5 would be the center of the text). (default 0)
drawTileImage (frame)
Draws a tile frame on the currently set tile. A tile frame is supposed to lay flat on the ground. The magic of this function is to draw the frame correctly on slopes. Use this function e.g. for drawing tool markers on the ground.

Parameters:

  • frame integer or draft A frame or draft (that contains at least one frame).
drawTriangle (x0, y0, x1, y1, x2, y2)
Draws a triangle.

Parameters:

  • x0 number X component of the first point.
  • y0 number Y component of the first point.
  • x1 number X component of the second point.
  • y1 number Y component of the second point.
  • x2 number X component of the third point.
  • y2 number Y component of the third point.
getAdditive ()
Returns the current additive factor for drawing.

Returns:

    number Additive factor ranging from 0 (not additive) to 1 (fully additive).
getAlpha ()
Returns the current transparency for drawing.

Returns:

    number Transparency value ranging from 0 (transparent) to 1 (opaque).
getColor ()
Returns the current drawing color.

Returns:

  1. integer Red comoponent of the drawing color.
  2. integer Green comoponent of the drawing color.
  3. integer Blue comoponent of the drawing color.
getImageHandle (frame)
Returns the handle of an image/frame.

Parameters:

  • frame integer or draft A frame or draft (that contains at least one frame) for which the handle location will be queried.

Returns:

  1. number X handle of the frame (in pixels).
  2. number y handle of the frame (in pixels).
getImageSize (frame)
Returns the size of an image/frame.

Parameters:

  • frame integer or draft A frame or draft (that contains at least one frame) for which the size will be queried.

Returns:

  1. number Width of the frame (in pixels).
  2. number Height of the frame (in pixels).
getScale ()
Returns the current scale factors set by setScale.

Returns:

  1. number Scaling factor for x axis.
  2. number Scaling factor for y axis.
getSize ()
Returns the current screen size width, height in pixels. Note that the result may change over time due to resolution changes.

Returns:

    number, number
getTextSize (text[, font=nil])
Queries the drawing size for a given text.

Parameters:

  • text string The text to calculate the size of (in pixels).
  • font font The font to calculate the size for. (default nil)

Returns:

  1. number Width required to draw the text.
  2. number Height required to draw the text.
reset ()
Resets all drawing properties. It's good practice to call this function before using other Drawing functions.
resetClipping ()
Resets clipping so that draw functions affect all pixels again.
setAdditive (additive)
Sets the additive factor used for additive drawing. Additive drawing simply adds the colors to the background instead of mixing them.

Parameters:

  • additive number The additivity factor to use. 0 being non additive, 1 being fully additive.
setAlpha (alpha)
Sets the transparency for drawing.

Parameters:

  • alpha number The transparency to use. 0 being fully transparent, 1 being fully opaque.
setClipping (x, y, w, h)
Sets the clipping rect to a specified rectangle. Consecutive calls to drawing functions will only afftect pixels within that rectangle.

Parameters:

  • x number The x coordinate for clipping.
  • y number The y coordinate for clipping.
  • w number The width for clipping.
  • h number The height for clipping.
setColor (r, g, b)
Sets the drawing color. Component values range from 0 to 255 with 0,0,0 being black and 255,255,255 being white. When drawing things the drawing color is applied in a multiplicative way. So using white as drawing color won't alter the color of images when drawing.

Parameters:

  • r integer Red component of the color.
  • g integer Green component of the color.
  • b integer Blue component of the color.
setScale (scaleX, scaleY)
Sets the scale for drawing (absolute). 1 for both of them would mean no scaling at all while values greater than 1 will scale things up. values smaller than 1 will draw things smaller.

Parameters:

  • scaleX number Scaling factor for x axis.
  • scaleY number Scaling factor for y axis.
setTile (tileX, tileY[, offsetX=0[, offsetY=0[, localScaleX=1[, localScaleY=1]]]])
Sets the current drawing offset and scale to a certain tile on the map.

Parameters:

  • tileX integer X coordinate of the tile.
  • tileY integer Y coordinate of the tile.
  • offsetX number X offset for drawing (in pixels). (default 0)
  • offsetY number Y offset for drawing (in pixels). (default 0)
  • localScaleX number Additional scaling factor for x axis. (default 1)
  • localScaleY number Additional scaling factor for y axis. (default 1)
generated by LDoc 1.4.3 Last updated 2020-09-27 16:37:25