nitro

package
v0.0.0-...-36966ac Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2020 License: BSD-2-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Acell

type Acell struct {
	LoopStart int
	PlayMode  int // invalid, forward, forward loop, forward-reverse, forward-reverse loop
	Frames    []Frame
}

An animated cell.

func (*Acell) FrameAt

func (a *Acell) FrameAt(t int) (Frame, int)

Returns the Frame at time t.

type Animation

type Animation struct {
	// contains filtered or unexported fields
}

func NewAnimation

func NewAnimation(
	ncgr *NCGR,
	nclr *NCLR,
	ncer *NCER,
	nanr *NANR,
	nmcr *NMCR,
	nmar *NMAR,
) *Animation

func (*Animation) Render

func (a *Animation) Render() *gif.GIF

Render draws every frame and returns a GIF.

func (*Animation) RenderFrame

func (a *Animation) RenderFrame(t int) *image.Paletted

Render renders a single frame.

type Frame

type Frame struct {
	Duration int // 60 fps
	Cell     int
	Rotate   uint16 // angle in units of (tau/65536) radians
	ScaleX   int32  // in units of 1/4096
	ScaleY   int32  // in units of 1/4096
	X        int
	Y        int
}

A frame of an animated cell.

type Header struct {
	Magic      [4]byte
	BOM        uint16
	Version    uint16
	Size       uint32
	HeaderSize uint16
	ChunkCount uint16
}

A Header is the common header used in all nitro formats.

type NANR

type NANR struct {
	Cells []Acell
	// contains filtered or unexported fields
}

An NANR (nitro animation resource) sequences cells into animations.

func ReadNANR

func ReadNANR(r io.Reader) (*NANR, error)

type NARC

type NARC struct {
	// contains filtered or unexported fields
}

An NARC (nitro archive) holds files.

func ReadNARC

func ReadNARC(r ReadSeekerAt) (*NARC, error)

TODO: Rewrite to only need io.ReaderAt?

func (*NARC) FileCount

func (narc *NARC) FileCount() int

FileCount returns the number of files in the archive.

TODO: better name.

func (*NARC) Open

func (narc *NARC) Open(n int) (readerSize, error)

Open opens the nth file in the archive. It will attempt to decompress compressed files.

func (*NARC) OpenNANR

func (narc *NARC) OpenNANR(n int) (*NANR, error)

OpenNANR calls ReadNANR(narc.Open(n))

func (*NARC) OpenNCER

func (narc *NARC) OpenNCER(n int) (*NCER, error)

OpenNCER calls ReadNCER(narc.Open(n))

func (*NARC) OpenNCGR

func (narc *NARC) OpenNCGR(n int) (*NCGR, error)

OpenNCGR calls ReadNCGR(narc.Open(n)).

func (*NARC) OpenNCLR

func (narc *NARC) OpenNCLR(n int) (*NCLR, error)

OpenNCLR calls ReadNCLR(narc.Open(n))

func (*NARC) OpenNMAR

func (narc *NARC) OpenNMAR(n int) (*NMAR, error)

OpenNMAR calls ReadNMAR(narc.Open(n))

func (*NARC) OpenNMCR

func (narc *NARC) OpenNMCR(n int) (*NMCR, error)

OpenNMCR calls ReadNMCR(narc.Open(n))

func (*NARC) OpenRaw

func (narc *NARC) OpenRaw(n int) (*io.SectionReader, error)

OpenRaw opens the nth file in the archive, without attempting to decompress it.

type NCER

type NCER struct {
	// contains filtered or unexported fields
}

An NCER (nitro cell resource) describes a bank of cells. Cells define subregions of an NCGR.

func ReadNCER

func ReadNCER(r io.Reader) (*NCER, error)

func (*NCER) Cell

func (ncer *NCER) Cell(i int, ncgr *NCGR, pal color.Palette) *image.Paletted

Cell returns the image data for a cell. It panics if the cell index is out of bounds.

func (*NCER) Len

func (ncer *NCER) Len() int

Len returns the number of cells in the cell bank.

type NCGR

type NCGR struct {
	Data []byte
	// contains filtered or unexported fields
}

An NCGR (nitro character graphic resource) stores pixel data.

func ReadNCGR

func ReadNCGR(r io.Reader) (*NCGR, error)

func (*NCGR) Bounds

func (ncgr *NCGR) Bounds() image.Rectangle

func (*NCGR) Decrypt

func (ncgr *NCGR) Decrypt()

Decrypt decrypts the pixel data in the NCGR. This method is used for Pokémon and trainer sprites in D/P and HG/SS.

func (*NCGR) DecryptReverse

func (ncgr *NCGR) DecryptReverse()

DecryptReverse decrypts the pixel data in the NCGR. This method is used for Pokémon sprites in Pt.

func (*NCGR) Image

func (ncgr *NCGR) Image(pal color.Palette) *image.Paletted

func (*NCGR) IsTiled

func (ncgr *NCGR) IsTiled() bool

func (*NCGR) Pixels

func (ncgr *NCGR) Pixels() []byte

Pixels returns the pixel data

func (*NCGR) Tile

func (ncgr *NCGR) Tile(i, w, h int, pal color.Palette) image.Image

func (*NCGR) TiledImage

func (ncgr *NCGR) TiledImage(pal color.Palette) *Tiled

type NCLR

type NCLR struct {
	Colors []RGB15
	// contains filtered or unexported fields
}

An NCLR (nitro color resource) defines a color palette.

func ReadNCLR

func ReadNCLR(r io.Reader) (*NCLR, error)

func (*NCLR) Palette

func (nclr *NCLR) Palette(n int) color.Palette

type NMAR

type NMAR struct {
	Cells []Acell
	// contains filtered or unexported fields
}

func ReadNMAR

func ReadNMAR(r io.Reader) (*NMAR, error)

type NMCR

type NMCR struct {
	// contains filtered or unexported fields
}

A NMCR (nitro multi cell resource) composes animated cells.

func ReadNMCR

func ReadNMCR(r io.Reader) (*NMCR, error)

func (*NMCR) Len

func (nmcr *NMCR) Len() int

func (*NMCR) Mcell

func (nmcr *NMCR) Mcell(i int) []mobj

type RGB15

type RGB15 uint16

RGB15 represents a 15-bit color.Color, having five bits each of red, green, and blue.

func (RGB15) RGBA

func (rgb RGB15) RGBA() (r, g, b, a uint32)

func (RGB15) String

func (rgb RGB15) String() string

type ReadSeekerAt

type ReadSeekerAt interface {
	io.Reader
	io.ReaderAt
	io.Seeker
}

type Tiled

type Tiled struct {
	Pix     []uint8
	Stride  int // number of tiles per row
	Rect    image.Rectangle
	Palette color.Palette
}

Tiled is an image.Image whose pixels are stored as a sequence of 8x8 tiles. Since it is conceptually one-dimensional, its bounds may be undefined.

func NewTiled

func NewTiled(r image.Rectangle, pal color.Palette) *Tiled

func (*Tiled) At

func (t *Tiled) At(x, y int) color.Color

func (*Tiled) Bounds

func (t *Tiled) Bounds() image.Rectangle

func (*Tiled) ColorIndexAt

func (t *Tiled) ColorIndexAt(x, y int) uint8

func (*Tiled) ColorModel

func (t *Tiled) ColorModel() color.Model

func (*Tiled) PixOffset

func (t *Tiled) PixOffset(x, y int) int

PixOffset returns the index Pix that corresponds to the pixel at (x, y).

func (*Tiled) Set

func (t *Tiled) Set(x, y int, c color.Color)

func (*Tiled) SetColorIndex

func (t *Tiled) SetColorIndex(x, y int, index uint8)

func (*Tiled) Tile

func (t *Tiled) Tile(n, width, height int) *Tiled

Tile returns an image representing a portion of t. The upper left tile of the returned image will be the nth tile in t, and the tiles following the nth tile will fill the remaining width and height of the returned image from left to right, top to bottom. The returned value shares pixels with the original image.

Jump to

Keyboard shortcuts

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