Advanced Features

Lua scripting, font import, image import, and project management.

Lua Scripting

Miggy Draw includes a sandboxed Lua 5.4 environment for automating repetitive tasks, batch processing, and custom workflows.

Experimental

Lua scripting is experimental. Some APIs may change in future releases.

Script Basics

Create scripts from the Scripts tab in the sidebar. Each script has access to the current project and its assets.

-- Example: Fill all sprites with a checkerboard pattern
local project = MiggyProject.current()

for _, sprite in ipairs(project:getSprites()) do
    for y = 0, sprite:getHeight() - 1 do
        for x = 0, sprite:getWidth() - 1 do
            if (x + y) % 2 == 0 then
                sprite:setPixel(x, y, 1)
            else
                sprite:setPixel(x, y, 2)
            end
        end
    end
end

print("Processed " .. #project:getSprites() .. " sprites")

Bridge Objects

Scripts access Miggy Draw data through bridge objects:

Object Methods
MiggyProject current(), getSprites(), getBobs(), getBitmaps(), getPalettes(), createSprite(name, palette)
MiggyImage getWidth(), getHeight(), getPixel(x, y), setPixel(x, y, color), clear()
MiggyPalette getColor(index), setColor(index, hex), getBitplanes()

For safety, these functions are disabled in the sandbox: loadfile, dofile, io, os (except os.clock), debug, package.

Font Import

Convert TrueType fonts to bitmap fonts for use in your Amiga projects.

  1. Create a new font from the Fonts tab
  2. Click "Import from Font File"
  3. Select a .ttf or .otf file
  4. Configure the import settings:
    • Size: Target pixel height
    • Character range: Which glyphs to include
    • Threshold: Anti-aliasing cutoff for 1-bit conversion
  5. Preview and adjust individual glyphs in the font editor
Tip

Start with pixel fonts or bitmap-friendly fonts (like Chicago, Monaco, or Topaz) for best results. Highly detailed fonts lose quality at small sizes.

Image Import

Import existing images (PNG, JPEG, BMP) and convert them to Amiga-compatible assets.

  1. Choose File → Import Image
  2. Select the source file
  3. Configure import settings:
    • Target type: Sprite, BOB, or Bitmap
    • Dimensions: Resize or maintain aspect ratio
    • Color mapping: Create new palette or map to existing
    • Dithering: Optional for better color approximation

The importer automatically reduces colors to fit the target bitplane depth, using the nearest available palette colors.

Project Management

Miggy Draw uses SwiftData for persistent storage. Your projects are automatically saved as you work.

Project Organization

Export/Import Workflows

Format Use Case
JSON Bundle Backup, version control, sharing projects
ZIP Archive Complete code export with README
Individual Files Export single assets for other tools

Batch Operations

Export multiple projects at once from File → Export All Projects. Each project gets its own subfolder with complete code output.

Version Control

JSON bundles are text-based and diff-friendly. Consider committing your .miggydraw bundles to Git alongside your Amiga source code.