Selection

Selection()

Selection()
Selection(rectangle)

Creates a new empty selection, or with the given rectangle.

Selection.bounds

local rectangle = selection.bounds

Returns a rectangle with the bounds of the selection (if the rectangle is empty, is because there is no selection).

Selection.origin

local point = selection.origin
selection.origin = newPoint

Gets or sets the selection origin/position (a point). This can be used to move the selection edges (not the content).

Selection.isEmpty

local status = selection.isEmpty

Returns true if the selection is empty i.e. there are no pixels selected.

Selection:deselect()

selection:deselect()

Selection:select()

selection:select(rectangle)

Replaces the selection with the given rectangle. If you want to add a rectangle to the selection, you can use Selection:add().

Selection:selectAll()

selection:selectAll()

Selected the whole sprite canvas. Only valid for a sprite.selection.

Selection:add()

selection:add(rectangle)
selection:add(otherSelection)

Adds a new rectangle (or otherSelection) to the selection. Creating an union between the existent selected area and the given rectangle/otherSelection.

Selection:subtract()

selection:subtract(rectangle)
selection:subtract(otherSelection)

Subtracts the given rectangle (or otherSelection) from selection.

Selection:intersect()

selection:intersect(rectangle)
selection:intersect(otherSelection)

Creates an intersection in selection between the given rectangle (or otherSelection) and the already selected area in selection.

Selection:contains()

local status = selection:contains(point)
local status = selection:contains(x, y)

Returns true or false if the given point is inside the selection.