Documentation
¶
Overview ¶
Aseprite file parser/decoder
Index ¶
- type Ase
- type BlendMode
- type Cel
- type CelType
- type ColorDepth
- type ColorProfile
- type FlipBitMask
- type Layer
- func (l *Layer) Cel(frame int) *Cel
- func (l *Layer) GetTileset() *Tileset
- func (l *Layer) IsBackgroundLayer() bool
- func (l *Layer) IsCelEmpty(frame int) bool
- func (l *Layer) IsGroupCollapsed() bool
- func (l *Layer) IsGroupLayer() bool
- func (l *Layer) IsLocked() bool
- func (l *Layer) IsReferenceLayer() bool
- func (l *Layer) IsTilemapLayer() bool
- func (l *Layer) IsVisible() bool
- func (l *Layer) PreferLinkedCels() bool
- type LayerType
- type LoopDirection
- type Slice
- type SliceFrame
- type Tag
- type Tile
- type Tileset
- type UserData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Ase ¶ added in v1.1.0
type Ase struct {
ColorDepth ColorDepth
// Canvas size (width and height)
Size image.Point
// Pixel aspect ratio (width:height)
PixelRatio image.Point
// Timeline frame durations
Durations []time.Duration
// Layers. Layer indices increase from bottom to top in Aseprite UI.
Layers []*Layer
// HasLayersUUID indicates whether each layer in the file contains a Universally Unique Identifier.
HasLayersUUID bool
// Aseprite slices. https://www.aseprite.org/api/slice#slice
Slices []Slice
// Timeline animation tags
Tags []*Tag
// Tilesets used in Tilemap layers
Tilesets []*Tileset
// Palette of file
Palette color.Palette
// Palette index for used as transparent color in each layer. (only for indexed images)
TransparentIndex uint8
ColorProfile ColorProfile
}
func Read ¶
Read opens and parses an Aseprite file from the given filepath, optionally filtering to visible layers only
func ReadFs ¶ added in v1.1.0
ReadFs opens and parses an Aseprite file from a virtual filesystem, optionally filtering to visible layers only
func (*Ase) BuildTilemapImages ¶ added in v1.6.0
func (a *Ase) BuildTilemapImages()
BuildTilemapImages performs the final rasterization for all cels in tilemap layers. It iterates through the tile grid, resolves tile IDs via the associated tileset, and assembles the final image composite by applying bitmask flips (X/Y/D).
func (*Ase) GetLayerByName ¶ added in v1.5.0
GetLayerByName returns the first layer with the given name. Returns nil if no layer is found with that name.
func (*Ase) GetLayerByUUID ¶ added in v1.7.0
GetLayerByUUID returns the layer with the given UUID. Returns nil if no layer is found with that UUID.
func (*Ase) GetTagByName ¶ added in v1.7.8
GetTagByName returns the first Tag with the given name. Returns nil if no layer is found with that name.
type Cel ¶ added in v1.1.0
type Cel struct {
// LayerIndex is the raw index of the layer this cel belongs to.
LayerIndex int
// ZIndex defines the display order override.
// 0 = default, +N = show N layers forward, -N = show N layers back.
ZIndex int
// Cel position
Pos image.Point
// Cel Width and Cel Height. Pixel unit for Image layers.
//
// Number of tiles for Tilemap layers.
Size image.Point
// Cel image
Image image.Image
// Cel opacity. (0-255)
Opacity uint8
// Tiles contains the ID and flip flags for each tile in a tilemap layer.
// This is nil for regular image layers.
Tiles []Tile
// Type specifies if this cel is a Raw Image, Linked Cel, Compressed Image, or Tilemap.
Type CelType
// UserData contains extra information like text and color associated with the cel.
UserData
// contains filtered or unexported fields
}
A cel is an image in a specific xy-coordinate, and a specific layer/frame combination.
func (*Cel) BuildTilemapImage ¶ added in v1.5.0
func (c *Cel) BuildTilemapImage()
BuildTilemapImage rasterizes the tilemap cel into an image. It resolves each tile index against the associated tileset, applies bitmask transformations for flips (X/Y/D), and performs a draw-call to assemble the final pixel buffer into the Cel's Image field.
type ColorDepth ¶ added in v1.4.0
type ColorDepth uint16
const ( NRGBA ColorDepth = 32 // Grayscale mode is parsed as image.NRGBA images. Grayscale ColorDepth = 16 Indexed ColorDepth = 8 )
func (ColorDepth) String ¶ added in v1.4.0
func (i ColorDepth) String() string
type ColorProfile ¶ added in v1.7.0
type FlipBitMask ¶ added in v1.5.0
type FlipBitMask uint8
const ( //Bitmask for X flip FlipX FlipBitMask = 1 << iota // Bitmask for Y flip FlipY // Bitmask for diagonal flip (swap X/Y axis) FlipD )
func (FlipBitMask) IsFlipD ¶ added in v1.5.0
func (f FlipBitMask) IsFlipD() bool
is diagonal flip (swap X/Y axis)
func (FlipBitMask) String ¶ added in v1.5.0
func (i FlipBitMask) String() string
type Layer ¶ added in v1.1.0
type Layer struct {
// Layer name.
Name string
// Layer's universally unique identifier.
//
// This field is uuid.Nil (all zeros) if Ase.HasLayersUUID is false.
UUID uuid.UUID
// Layer type
Type LayerType
// Layer flags
Flags uint16
// Blending mode of this layer.
BlendMode BlendMode
// Layer opacity. (0-255)
Opacity uint8
// Index matches the frame number
Cels []*Cel
// The child level is used to show the relationship of this layer with the last one read.
//
// https://github.com/aseprite/aseprite/blob/main/docs/ase-file-specs.md#note1
ChildLevel uint16
// Index for Ase.Tilesets[]
TilesetIndex uint32
UserData
// contains filtered or unexported fields
}
func (*Layer) GetTileset ¶ added in v1.6.0
GetTileset returns the Tileset used by Tilemap layers. It returns nil if layer is not a tilemap.
func (*Layer) IsBackgroundLayer ¶ added in v1.7.5
func (*Layer) IsCelEmpty ¶ added in v1.5.0
IsCelEmpty checks if the frame has no content.
func (*Layer) IsGroupCollapsed ¶ added in v1.7.5
func (*Layer) IsGroupLayer ¶ added in v1.7.8
func (*Layer) IsReferenceLayer ¶ added in v1.7.5
func (*Layer) IsTilemapLayer ¶ added in v1.7.8
func (*Layer) PreferLinkedCels ¶ added in v1.7.5
type LoopDirection ¶
type LoopDirection uint8
const ( Forward LoopDirection = iota Reverse PingPong PingPongReverse )
func (LoopDirection) String ¶ added in v1.4.0
func (i LoopDirection) String() string
type Slice ¶
type Slice struct {
UserData
Name string
Frames []SliceFrame
}
type SliceFrame ¶ added in v1.1.0
type Tag ¶
type Tag struct {
Name string
// Frame index where this tag starts.
Start int
// Frame index where this tag ends.
End int
// Play this animation section N times, 0 means infinite.
Repeat uint16
LoopDirection LoopDirection
UserData
}
Tag Represents a tag in the timeline.
type Tile ¶ added in v1.5.0
type Tile struct {
ID uint32 // Tile index
XYD FlipBitMask // XYD bitmask flags
}
type Tileset ¶ added in v1.5.0
type Tileset struct {
// Tileset name
Name string
// Tileset ID
ID uint32
// Tile width/height
TileSize image.Point
NumTiles int
// Tileset image containing all tiles vertically (Present if Flags & 2 is set)
Image image.Image
// Tileset flags
//
// 1 - Include link to external file
//
// 2 - Include tiles inside this file
//
// 4 - Tilemaps using this tileset use tile ID=0 as empty tile
// (this is the new format). In rare cases this bit is off,
// and the empty tile will be equal to 0xffffffff (used in
// internal versions of Aseprite)
//
// 8 - Aseprite will try to match modified tiles with their X
// flipped version automatically in Auto mode when using
// this tileset.
//
// 16 - Same for Y flips
//
// 32 - Same for D(iagonal) flips
Flags uint32
// External file data (Present if Flags & 1 is set)
ExternalFileID uint32
ExternalTilesetID uint32
// Index to show in the UI (usually 1)
BaseIndex int
}
Tileset represents a set of tiles defined in the .ase file (Chunk 0x2023)