SpriteGrid

Developer documentation

Effects tools

4 tools. Every change a tool makes is one undo step in SpriteGrid.

list_effectsEffects SpriteGrid haslooks only

The effects that can be put on a layer (outline, drop shadow, glow, palette snap...): what each does and its settings, with their types, ranges and defaults. describe_document shows the effects each layer has.

Parameters

Nothing.

Returns
effectslist of objectsrequired

Every effect, by category.

5 fields
idstringrequired

Pass it as `effect` to add_effect.

namestringrequired
categorystringrequired
descriptionstringrequired
settingslist of objectsrequired
7 fields
idstringrequired

Its id, the key in `settings`.

namestringrequired
typestringrequired

integer, number, boolean, color, pair ({ "x", "y" }), choice (one of options, by name), gradient (points) or palette (colors).

defaultanyrequired

What it is when the effect is added.

minnumberrequired
maxnumberrequired
optionslist of stringsrequired

A choice's options.

add_effectAdd an effect

Puts an effect on a layer, with the settings you give (the rest keep their defaults; a palette setting starts as the document's palette). Effects are applied in their list order. Returns its id. Check it with render_preview, which shows effects.

Parameters

effectstringrequired

Which effect: its id from list_effects, like "outline", or its name.

layerstring

Which layer: its id, or its exact name (describe_document lists them). Leave it out for the layer selected in SpriteGrid.

settingsobject

Settings by id (list_effects has each effect's): numbers, true/false, colors as "#RRGGBB", a choice by name, a pair as { "x": 1, "y": 1 }, a gradient as [{ "at": 0, "color": "#000000" }, { "at": 1, "color": "#ffffff" }], a palette as a list of colors. Example: { "thickness": 1, "color": "#282a36" }.

enabledboolean

False to add it turned off.

indexinteger

Where in the layer's list: 0 is applied first. Leave it out to add it last.

documentstring

Which document: its id from get_status (like "doc-1"), its path, or its name. Leave it out for the one you're working on, or the one shown in SpriteGrid before you've worked on one.

expectedRevisioninteger

The document's revision when you looked at it: if the document has changed since (the user edited it, say), nothing is done and you're told so.

Returns
documentstringrequired

The document's id.

revisionintegerrequired

Its revision after the change.

summarystringrequired

What changed, in a line.

layerstring

The layer changed or made, if there was one.

changedobject

The rectangle of pixels that changed, if any did.

4 fields
xintegerrequired

Left edge, in pixels from the left of the canvas.

yintegerrequired

Top edge, in pixels from the top of the canvas.

widthintegerrequired

Width in pixels.

heightintegerrequired

Height in pixels.

pixelsChangedinteger

How many pixels changed.

slicestring

The slice changed or made, if there was one.

effectstring

The effect changed or added, if there was one.

tilestring

The tile changed or made, if there was one.

update_effectChange an effect

Changes an effect's settings, turns it on or off, or moves it in the layer's list — any of them, in one undo step. What you leave out stays as it is.

Parameters

effectstringrequired

Which effect: its id (describe_document lists each layer's effects), or its kind, like "outline", if the layer has just one.

layerstring

The layer it's on. Leave it out when effect is an id.

settingsobject

Settings by id (list_effects has each effect's): numbers, true/false, colors as "#RRGGBB", a choice by name, a pair as { "x": 1, "y": 1 }, a gradient as [{ "at": 0, "color": "#000000" }, { "at": 1, "color": "#ffffff" }], a palette as a list of colors. Example: { "thickness": 1, "color": "#282a36" }.

enabledboolean

True to turn it on, false to turn it off.

indexinteger

Move it to here in the layer's list: 0 is applied first.

documentstring

Which document: its id from get_status (like "doc-1"), its path, or its name. Leave it out for the one you're working on, or the one shown in SpriteGrid before you've worked on one.

expectedRevisioninteger

The document's revision when you looked at it: if the document has changed since (the user edited it, say), nothing is done and you're told so.

Returns
documentstringrequired

The document's id.

revisionintegerrequired

Its revision after the change.

summarystringrequired

What changed, in a line.

layerstring

The layer changed or made, if there was one.

changedobject

The rectangle of pixels that changed, if any did.

4 fields
xintegerrequired

Left edge, in pixels from the left of the canvas.

yintegerrequired

Top edge, in pixels from the top of the canvas.

widthintegerrequired

Width in pixels.

heightintegerrequired

Height in pixels.

pixelsChangedinteger

How many pixels changed.

slicestring

The slice changed or made, if there was one.

effectstring

The effect changed or added, if there was one.

tilestring

The tile changed or made, if there was one.

remove_effectRemove an effectdeletes

Takes an effect off its layer, with any animation of its settings. Undo brings it back.

Parameters

effectstringrequired

Which effect: its id (describe_document lists each layer's effects), or its kind, like "outline", if the layer has just one.

layerstring

The layer it's on. Leave it out when effect is an id.

documentstring

Which document: its id from get_status (like "doc-1"), its path, or its name. Leave it out for the one you're working on, or the one shown in SpriteGrid before you've worked on one.

expectedRevisioninteger

The document's revision when you looked at it: if the document has changed since (the user edited it, say), nothing is done and you're told so.

Returns
documentstringrequired

The document's id.

revisionintegerrequired

Its revision after the change.

summarystringrequired

What changed, in a line.

layerstring

The layer changed or made, if there was one.

changedobject

The rectangle of pixels that changed, if any did.

4 fields
xintegerrequired

Left edge, in pixels from the left of the canvas.

yintegerrequired

Top edge, in pixels from the top of the canvas.

widthintegerrequired

Width in pixels.

heightintegerrequired

Height in pixels.

pixelsChangedinteger

How many pixels changed.

slicestring

The slice changed or made, if there was one.

effectstring

The effect changed or added, if there was one.

tilestring

The tile changed or made, if there was one.