pix

package
v0.0.0-...-4ede3f3 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2022 License: BSD-2-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package pix provides models and helpers to work with paletted pixel graphics.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClipNamedUnique

func ClipNamedUnique(lt *ids.ListTable[ids.Clip, Clip, *Clip], img ids.Img, name string) error

Types

type Clip

type Clip struct {
	ID   ids.Clip `json:"id"`
	Name string   `json:"name"`
	Img  ids.Img  `json:"img"`
	geo.Dim
	Seq  []Frame `json:"seq"`
	Loop bool    `json:"loop,omitempty"`
}

Clip is a named sequence of frames for animation.

func (*Clip) Make

func (*Clip) Make(id uint32) Clip

func (*Clip) MarshalBinary

func (c *Clip) MarshalBinary() ([]byte, error)

func (*Clip) Named

func (c *Clip) Named() string

func (*Clip) UID

func (c *Clip) UID() uint32

func (*Clip) UnmarshalBinary

func (c *Clip) UnmarshalBinary(raw []byte) error

type ClipTable

type ClipTable = ids.ListTable[ids.Clip, Clip, *Clip]

type Color

type Color uint32

func RGB

func RGB(r, g, b uint8) Color

func RGBT

func RGBT(r, g, b, t uint8) Color

func Shades

func Shades(c Color) []Color

Shades returns a list of four different shades of the given color. From lightest to darkest: lighter, color, darker and outline

func (Color) A

func (c Color) A() uint8

func (Color) MarshalText

func (c Color) MarshalText() ([]byte, error)

func (Color) Max

func (c Color) Max() (m uint8)

func (Color) RGB

func (c Color) RGB() (r, g, b uint8)

func (Color) T

func (c Color) T() uint8

func (*Color) UnmarshalText

func (c *Color) UnmarshalText(raw []byte) error

type Feat

type Feat struct {
	Name   string  `json:"name"`
	Colors []Color `json:"colors"`
}

type Frame

type Frame struct {
	Pic   ids.Pic `json:"pic"`
	Dur   uint    `json:"dur,omitempty"`
	Marks []Mark  `json:"marks,omitempty"`
}

Frame represents a specific picture for a given duration.

type Img

type Img struct {
	ID   ids.Img `json:"id"`
	Name string  `json:"name"`
	Kind string  `json:"kind"`
	geo.Dim
	Pal ids.Pal `json:"pal"`
}

func (*Img) Make

func (*Img) Make(id uint32) Img

func (*Img) MarshalBinary

func (im *Img) MarshalBinary() ([]byte, error)

func (*Img) Named

func (im *Img) Named() string

func (*Img) UID

func (im *Img) UID() uint32

func (*Img) UnmarshalBinary

func (im *Img) UnmarshalBinary(raw []byte) error

type ImgTable

type ImgTable = ids.ListTable[ids.Img, Img, *Img]

type Mark

type Mark struct {
	ID ids.Spot `json:"id"`
	geo.Pos
}

type Pal

type Pal struct {
	ID    ids.Pal `json:"id"`
	Name  string  `json:"name"`
	Kind  string  `json:"kind"`
	Feats []*Feat `json:"feats"`
}

func (*Pal) Color

func (pal *Pal) Color(p Pixel) Color

func (*Pal) Feat

func (pal *Pal) Feat(name string) *Feat

func (*Pal) Make

func (*Pal) Make(id uint32) Pal

func (*Pal) MarshalBinary

func (p *Pal) MarshalBinary() ([]byte, error)

func (*Pal) Named

func (p *Pal) Named() string

func (*Pal) UID

func (p *Pal) UID() uint32

func (*Pal) UnmarshalBinary

func (p *Pal) UnmarshalBinary(raw []byte) error

type PalTable

type PalTable = ids.ListTable[ids.Pal, Pal, *Pal]

type Pic

type Pic struct {
	ID ids.Pic `json:"id"`
	Pix
}

Pic represents a picture as part of an asset.

func (*Pic) Make

func (*Pic) Make(id uint32) Pic

func (*Pic) MarshalBinary

func (p *Pic) MarshalBinary() ([]byte, error)

func (*Pic) UID

func (p *Pic) UID() uint32

func (*Pic) UnmarshalBinary

func (p *Pic) UnmarshalBinary(raw []byte) error

type PicTable

type PicTable = ids.ListTable[ids.Pic, Pic, *Pic]

type Pix

type Pix = grid.Tiles[Pixel]

Pix is a grid of pixels.

func MakePix

func MakePix(x, y, w, h int, pix ...uint16) Pix

type Pixel

type Pixel uint16

Pixel is numeric id into the palette.

type Spot

type Spot struct {
	ID    ids.Spot `json:"id"`
	Name  string   `json:"name"`
	Color uint32   `json:"color"`
	geo.Dim
}

func (*Spot) Make

func (*Spot) Make(id uint32) Spot

func (*Spot) MarshalBinary

func (s *Spot) MarshalBinary() ([]byte, error)

func (*Spot) Named

func (s *Spot) Named() string

func (*Spot) UID

func (s *Spot) UID() uint32

func (*Spot) UnmarshalBinary

func (s *Spot) UnmarshalBinary(raw []byte) error

type SpotTable

type SpotTable = ids.ListTable[ids.Spot, Spot, *Spot]

type Sys

type Sys struct {
	Pal  PalTable
	Img  ImgTable
	Clip ClipTable
	Pic  PicTable
	Spot SpotTable
}

func (*Sys) DelClip

func (s *Sys) DelClip(id ids.Clip) error

func (*Sys) DelImg

func (s *Sys) DelImg(id ids.Img) error

func (*Sys) DelPal

func (s *Sys) DelPal(id ids.Pal) error

func (*Sys) DelSpot

func (s *Sys) DelSpot(id ids.Spot) error

func (*Sys) GetClip

func (s *Sys) GetClip(img ids.Img, name string) *Clip

func (*Sys) NewClip

func (s *Sys) NewClip(req Clip) (*Clip, error)

func (*Sys) NewImg

func (s *Sys) NewImg(a Img) (*Img, error)

func (*Sys) NewPal

func (s *Sys) NewPal(name string) (*Pal, error)

func (*Sys) NewSpot

func (s *Sys) NewSpot(a Spot) (*Spot, error)

Jump to

Keyboard shortcuts

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