Class Image
Used to place an image.
Class Image
image:new () | Constructor. |
Class Image
Represents an image.
- image:new ()
-
Constructor.
path
: a string. Path to the image (filename
in love2d).quad
: a table. It contains information about quads in the image. It has two fields:layout
: a table of the form{ rows = n, columns = m }
, wheren
andm
are positive integers.current
: a positive integer. The current quad index. The quad index goes from left to right, top to bottom.
Default
quad
isself.quad = { layout = { rows = 1, columns = 1, }, current = 1, }
i.e. if not specified it is assumed there is only one quad in the image - the image itself. NOTE: the quads must
- be of the same size.
- not have spacing in between.
- be placed in a grid
quad.layout.rows
byquad.layout.columns
inside the image.
Provided you have an image at
path/to/my/awesome/image.png
that looks like this:┌────────┬────────┐ │ ▚▞ │ ▞▚ │ │ │ │ │ │ │ ├────────┼────────┤ │ ▞ │ ▞ │ │ ▚ │ ▞ │ │ │ │ └────────┴────────┘
the code
local image = ui.Image { path = 'path/to/my/awesome/image.png', quad = { layout = { rows = 2, columns = 2, }, current = 3, } } image:place(0, 0, 100, 100) image:draw()
will draw:
┌────────┐ │ ▞ │ │ ▚ │ │ │ └────────┘