Retro Sketch Plugin API | Retro Sketch Documentation

For the most part you can view all of the API functions and their descriptions in the rsapi.lua file, located next to the RetroSketch.exe.

Terminology

Layer: The base drawing element where pixels are stored. When using Retro Sketch, a layer is a single entry in the window on the left of the screen. You have multiple layers in a single canvas.

Canvas: A canvas is made up of multiple layers stacked on top of each other. A canvas can be considered a single frame of animation, though you can hold a canvas for any number of frames. A canvas is represented in Retro Sketch at the bottom of the window. You have multiple canvases in a single track.

Track: A track is made up of multiple canvases. Tracks can be stacked on top of each other to create complex animations. In Retro Sketch, a track is represented by all of the canvases listed in the bottom of the window. When you click on the timeline icon, you are taken to the timeline view which shows many tracks.

Color: A 4-byte representation of a color in the format (R, G, B, A) where each channel takes up one byte and is a number between 0 and 255. You can represent a color in hex as in 0xFF0000AA (red), or 0x00FF00FF (green), etc.

Coordinates: Coordinates are the X and Y values representing a location on the canvas. The top left corner is <1, 1> (<x, y>), and the bottom right corner is <xn, ym> where "n" and "m" are the width and height of the project respectively. An example of this can be seen at the top of the Retro Sketch window when you have "show coordinates" enabled in the settings.

Design

Your code should be designed to either do a single-time execution, or be self managed within the UI layouts you construct. You are to manage your own UI and properly destroy the UI you are no longer using.

Your Lua scripts should be designed as a single Lua file. If you develop a complex plugin, you can use multiple files, but you should use some-sort of rollup system to compile all of your lua code into a singular file for distribution.

When distributing your Lua file, you should use a short, unique name for the file name. This name will be used for the menu bar's listing of plugins.

If you wish for your plugin to live for the lifetime of Retro Sketch's execution, you'll need to place it into a global variable for tracking. You should show/hide your UI when appropriate, and you should place your code within a global table as if it were a namespace. Try picking something unique like your special online handle or something like that so it doesn't clash with everyone elses.

You should use local functions and local assignments at all times. If you're making a library of functions for others to use globally, you should still place them within your unique namespace.