ImageSheetPaint

Parent Paint
Library display.*
Revision Release 2024.3703
Keywords imageSheetPaint
See also object.fill
object.stroke

Overview

An image sheet paint is a special kind of BitmapPaint used to fill/stroke an object with an image sheet frame.

Gotchas

It is not possible to use texture wrap modes (reference) in conjunction with image sheet frames. This is because OpenGL only supports wrap modes on entire textures, not subsections of textures.

Syntax

local paint = {
    type = "image",
    sheet = ,
    frame =
}
type (required)

String. String value of "image".

sheet (required)

ImageSheet. An image sheet object returned by graphics.newImageSheet().

frame (required)

Number. The frame index from the image sheet.

Properties

(Inherits properties from Paint)

Example

-- Set up the image sheet
local options =
{
    width = 40,
    height = 100,
    numFrames = 8,
    sheetContentWidth = 160,  -- width of original 1x size of entire sheet
    sheetContentHeight = 200  -- height of original 1x size of entire sheet
}
local imageSheet = graphics.newImageSheet( "textures.png", options )

-- Create a vector rectangle
local rect = display.newRect( 200, 200, 300, 300 )

-- Set the fill (paint) to use frame #2 from the image sheet
local paint = {
    type = "image",
    sheet = imageSheet,
    frame = 2
}

-- Fill the rectangle
rect.fill = paint