ase

package module
v0.1.0-alpha.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 17, 2020 License: MIT Imports: 10 Imported by: 0

README

go-ase

go-ase implements a decoder for the aseprite file format.

It implements just enough of the format to be able to decode and render aseprite files. It does not have the ability to encode aseprite files.

Documentation

Overview

Package ase implements decoding and encoding .ase/.aseprite files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cel

type Cel struct {
	Layer   uint16     // The cel layer.
	Opacity byte       // The cel opacity.
	Type    CelType    // The cel type.
	Width   uint16     // The width of the cel in pixels.
	Height  uint16     // The height of the cel in pixels.
	Image   draw.Image // The cel image.
	Link    uint16     // The frame this cel is linked to.
}

Cel represent a cel.

func (Cel) At

func (c Cel) At(x, y int) color.Color

At returns the color of the pixel at (x, y).

func (Cel) Bounds

func (c Cel) Bounds() image.Rectangle

Bounds returns the bounds of the cel.

func (Cel) ColorModel

func (c Cel) ColorModel() color.Model

ColorModel returns the color model of the cel.

func (Cel) Set

func (c Cel) Set(x, y int, clr color.Color)

Set sets the color of the pixel at (x, y).

type CelType

type CelType uint16
const (
	CelTypeRaw CelType = iota // Deprecated: Use CelTypeCompressed instead
	CelTypeLinked
	CelTypeCompressed
)

type File

type File struct {
	Width  uint16      // Width in pixels.
	Height uint16      // Height in pixels.
	Model  color.Model // Color model.
	Frames []Frame     // Frames.
	Layers []Layer     // Layers.
	Tags   []Tag       // Tags.
}

File represents an aseprite file.

func Decode

func Decode(r io.Reader) (*File, error)

Decode attempts to decode an aseprite file from the given io.Reader.

func (*File) Render

func (f *File) Render(options *RenderOptions) *image.NRGBA

Render renders the file to an image. Frames are arranged horizontally. Splits are arranged vertically.

type Frame

type Frame struct {
	Duration uint16 // The duration of the frame in milliseconds.
	Cels     []Cel  // Cels in the frame.
}

Frame represents a single frame.

func (*Frame) GetLayer

func (f *Frame) GetLayer(layer uint16) *Cel

GetLayer returns the cel with the given layer, or nil if none.

type Layer

type Layer struct {
	Name    string
	Alpha   uint8
	Visible bool
}

Layer represents a layer.

type RenderOptions

type RenderOptions struct {
	PadX  int    // How much padding to put between each frame.
	Split Split  // How to split the file.
	Frame int    // The frame to render.
	Layer string // The layer to render.
	Tag   string // The tag to render.
}

RenderOptions contains various options for rendering a file.

type Split

type Split int

Split enumerates different ways of splitting a file.

const (
	SplitFrames Split = iota // Split the file by frames.
	SplitLayers              // Split the file by layers.
	SplitTags                // Split the file by tags.
)

type Tag

type Tag struct {
	From uint16 // First frame.
	To   uint16 // Last frame.
	Dir  byte   // Loop direction. 0 = Forward, 1 = Reverse, 2 = Ping-pong
	Name string // Tag name.
}

Tag represents an annotated group of frames.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL