Editor

References a sprite editor. At the moment we can access only the active editor using app.editor.

Editor.sprite

local sprite = app.editor.sprite

Returns the sprite in the editor.

Editor.spritePos

local point = app.editor.spritePos

Returns a point of the the mouse position on the sprite, i.e. what pixel is going to be changed if the user clicks the mouse.

Editor.mousePos

local point = app.editor.mousePos

Returns a point indicating the mouse position on the screen.

Editor:askPoint()

app.editor:askPoint{
  title=string,
  point=initialPoint,
  onclick=function(ev) ... end,
  onchange=function(ev) ... end,
  oncancel=function(ev) ... end,
}

Asks the user to select a pixel/point on the sprite. It's similar to what happens when you choose Edit > New Brush (but in that case you select a rectangle).

  • title: Text to show in the context bar
  • point: Initial point to highlight (optional)
  • onclick: Happens when the user clicks (press/release a mouse button) on the canvas
  • onchange: Happens when the user drags the mouse (press/move mouse/release a mouse button) on the canvas
  • oncancel: Happens when the user cancels the action (e.g. press the Escape key)

Editor:cancel()

app.editor:cancel()

Cancels the editor:askPoint() action.