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.zoom

app.editor.zoom = 0.33333333333
local zoom = app.editor.zoom

local percentage = zoom * 100 -- 33.3%

Gets or sets the editor zoom as a float. To get a percentage, multiply by 100.

Editor.scroll

local scroll = app.editor.scroll 
app.editor.scroll = scroll

Gets or sets the editor scroll (coordinates of sprite pixel to center the editor at) as a table, with values x and y as floats.

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.