← back to roto on ba3a.dev

Package-level declarations

Types

Link copied to clipboard
class AseModelSource(file: Path, canvas: Canvas, defaultLoop: Boolean) : ModelSource

An .ase or .aseprite file as animations. Each frame is its visible layers composited cel by cel (cel position, layer and cel opacity, palette colour), durations come from the file. Each tag becomes one row; a file without tags gives one row of all its frames. A tag sets the loop flag (repeating forever loops); without a tag the artist's defaultLoop applies. A file outside the supported subset fails with the AseFormatException as it is.

Link copied to clipboard
class AtlasModelSource(file: Path, canvas: Canvas, actions: List<String>, facings: List<String>, pattern: Template, durationMs: Map<String, Int> = emptyMap(), loops: Set<String> = emptySet()) : ModelSource

A libGDX .atlas file (its page PNGs beside it) as animations. Each region is matched against the name pattern for every action and facing of the project; the matches of one action and facing, ordered by frame number, are one row. Regions that match nothing are skipped and listed in skipped. An atlas carries no durations, so each action has the artist's duration and loop flag. A region smaller than the canvas is placed on it by ModelCanvas; a larger one stops the import, naming both sizes.

Link copied to clipboard
data class AtlasPage(val name: String, val regions: List<AtlasRegion>)

One page of an atlas: its PNG file name and the regions on it.

Link copied to clipboard

Reads the libGDX TexturePacker text format and rebuilds frames from it. Pure over the atlas text and page rasters; the caller loads the page PNGs.

Link copied to clipboard
data class AtlasRegion(val name: String, val index: Int, val x: Int, val y: Int, val width: Int, val height: Int, val origWidth: Int, val origHeight: Int, val offsetX: Int, val offsetY: Int)

One region of a libGDX atlas page: where its crop sits on the page and where that crop sits in the original frame.

Link copied to clipboard
data class ConfirmedRow(val row: ModelRow, val action: String, val facing: String)

One row of a ModelSource the artist confirmed.

Link copied to clipboard
data class FigureBox(val left: Int, val top: Int, val right: Int, val bottom: Int)

The inclusive pixel bounds of a figure in one frame.

Link copied to clipboard
data class FrameMeasure(val box: FigureBox?, val rootX: Int?)

What ModelMeasure finds in one frame.

Link copied to clipboard

The one rule for a model frame drawn smaller than the project canvas, shared by every ModelSource: it is placed centred across, its bottom row on the canvas's bottom row, so the feet stay on the ground. Roto never rescales a model, so a frame larger than the canvas either way is refused.

Link copied to clipboard
class ModelClip(val action: String, val facing: String, val frames: List<ModelFrame>, val loop: Boolean, val origin: String)

One finished animation the artist imported as reference: an action and facing, its frames at one size with their durations, and whether it loops. A model is read-only; it is stored under the profile's models/<action>_<facing>/ folder.

Link copied to clipboard

Reads and writes a model's model.json as a ModelManifest.

Link copied to clipboard
data class ModelColours(val ramps: List<RampUse>, val usesOutline: Boolean, val outside: List<Int>)

Which ramps and steps a model's colours come from.

Link copied to clipboard
class ModelException(message: String, cause: Throwable? = null) : IOException

A model's model.json or frames could not be read, written or understood; the message says why.

Link copied to clipboard
fun interface ModelFileWriter

How ModelRepository.save performs one file write: runs write, which creates file. A seam for tests.

Link copied to clipboard
class ModelFrame(val raster: Raster, val durationMs: Int)

One frame of a ModelClip: its picture and how long it shows.

Link copied to clipboard
class ModelImporter(profileFolder: ProfileFolder, config: ProjectConfig)

Turns a ModelSource and the artist's confirmed rows into model folders under a profile. All rows are checked first, then staged in a temporary folder with model.json written last in each, then moved into place; a failure leaves the profile as it was. A key that already exists is refused unless replace is true. The same source always gives byte-identical folders.

Link copied to clipboard
@Serializable
data class ModelManifest(val action: String, val facing: String, val loop: Boolean, val durations: List<Int>, val importedFrom: String)

A model's model.json: everything about a ModelClip except its frame pictures, which sit beside it as 000.png, 001.png, and so on.

Link copied to clipboard

Measures a model's geometry from its frames' alpha. A pixel with alpha of at least FIGURE_ALPHA is figure. The clip's top and feet rows are the medians of its figure frames' own (the lower median of an even count), so one stray frame does not move them; the body height is the span between them. Integer arithmetic only, except the hip band that RootFinder already defines.

Link copied to clipboard
data class ModelMeasurement(val frames: List<FrameMeasure>, val bodyHeight: Int?, val feetRow: Int?)

What ModelMeasure finds in a whole clip.

Link copied to clipboard
class ModelRepository(profileFolder: ProfileFolder)

The models of one profile, under its models/ folder: one <action>_<facing>/ folder each, holding model.json and the frames 000.png, 001.png, and so on. A folder that cannot be read fails with a ModelException naming the file.

Link copied to clipboard
data class ModelRow(val id: String, val action: String?, val facing: String?, val frameCount: Int)

One animation a ModelSource found: what the import dialog lists, one row per proposed model.

Link copied to clipboard
interface ModelSource

Where a model's frames come from: a folder of PNGs, an .ase file or an atlas. Each reader hands back the same normalised parts, so the importer never knows the format. A frame that is not canvas size fails with a ModelException naming both sizes; Roto never rescales a model.

Link copied to clipboard

What a path the artist picked holds.

Link copied to clipboard

Picks and builds the ModelSource for a path: the artist chooses a file or folder, never a format.

Link copied to clipboard

Key frames for a clip taken from a ModelClip's timing: one key frame per model frame, each boundary at the model's relative time along the clip's detected cycle. A cycle whose length differs from the model's total duration scales the boundaries proportionally; they round to frame starts and stay strictly rising.

Link copied to clipboard
class PngFolderModelSource(folder: Path, canvas: Canvas, defaultDurationMs: Int, defaultLoop: Boolean) : ModelSource

A folder of PNG frames, sorted by file name, as one animation. A clip.json beside them (Roto's own ClipManifest) gives each frame's duration and the loop flag; without one every frame lasts defaultDurationMs and the loop flag is defaultLoop. A published clip folder works as it is.

Link copied to clipboard
data class RampUse(val ramp: String, val firstStep: Int, val lastStep: Int)

The steps of one ramp a model uses.

Properties

Link copied to clipboard

Frame duration in ms an action gets until the artist sets one.

Link copied to clipboard

The name pattern the import dialog starts with when the project's output template gives none.

Link copied to clipboard
const val FIGURE_ALPHA: Int = 128

The least alpha that counts as figure; a fainter pixel, such as a soft shadow, is background.

Functions

Link copied to clipboard

The name pattern for output: its path segments that name an action, facing or frame, joined by _, with the profile and the file extension left out. raw-art/{profile}/{action}_{facing:lower}/{frame:000}.png gives {action}_{facing:lower}_{frame:000}. An output that does not give a pattern using all three variables falls back to DEFAULT_ATLAS_PATTERN.