model

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SaveSprites

func SaveSprites() error

SaveSprites saves out the currently open SpriteSet

func SetPalette

func SetPalette(p *Palette)

SetPalette swaps the current Palette with a different one

func SetSprites

func SetSprites(set *SpriteSet)

SetSprites swaps out the current SpriteSet with a different one

Types

type Palette

type Palette struct {
	Name     string          `json:"name"`
	Author   string          `json:"author"`
	Date     time.Time       `json:"date"`
	Revision int             `json:"revision"`
	Colors   encoding.Colors `json:"colors"`
	// contains filtered or unexported fields
}

Palette is a color picker for a Palette of colors

func GetPalette

func GetPalette() *Palette

GetPalette returns the current Palette

func LoadPalette

func LoadPalette(path string) (p *Palette, err error)

LoadPalette reads a Palette from a JSON file and unmarshals it

func (Palette) BG

func (p Palette) BG() (index int, value color.Color)

BG returns the index and color of the background

func (*Palette) Describe

func (p *Palette) Describe()

Describe privides a simple description of the Palette with its Metadata

func (Palette) FG

func (p Palette) FG() (index int, value color.Color)

FG returns the index and color of the foreground

func (Palette) HasChanged

func (p Palette) HasChanged() bool

HasChanged indicates that this palette has undergone changes

func (*Palette) SetBG

func (p *Palette) SetBG(index int)

SetBG changes the BG color

func (*Palette) SetFG

func (p *Palette) SetFG(index int)

SetFG changes the FG color

func (*Palette) Update

func (p *Palette) Update() error

Update clears the changed state

type Sprite

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

Sprite holds the data for a single sprite

func GetSprite

func GetSprite(index int) *Sprite

GetSprite retrieves a sprite from the current SpriteSet

func (*Sprite) Bounds

func (s *Sprite) Bounds() image.Rectangle

Bounds returns the bounding box for this sprite

func (*Sprite) Clone

func (s *Sprite) Clone() (next *Sprite)

Clone creates a deep copy of this Sprite

func (*Sprite) HasChanged

func (s *Sprite) HasChanged() bool

HasChanged report if the Sprite has been edited or if the color palette has changed

func (*Sprite) Image

func (s *Sprite) Image() *image.Paletted

Image returns the internal image as a pointer

func (*Sprite) IsModified

func (s *Sprite) IsModified() bool

IsModified reports if this Sprite has edited

func (Sprite) MarshalJSON

func (s Sprite) MarshalJSON() (bs []byte, err error)

MarshalJSON is a custom marshaler for the Sprite type

func (*Sprite) Palette

func (s *Sprite) Palette() *Palette

Palette returns the color palette for this sprite

func (*Sprite) SetBG

func (s *Sprite) SetBG(x, y int)

SetBG sets the pixel at the specified location to the BG color

func (*Sprite) SetFG

func (s *Sprite) SetFG(x, y int)

SetFG sets the pixel at the specified location to the FG color

func (*Sprite) SetPalette

func (s *Sprite) SetPalette(colors *Palette)

SetPalette changes the color palette for this sprite

func (*Sprite) UnmarshalJSON

func (s *Sprite) UnmarshalJSON(b []byte) (err error)

UnmarshalJSON is a custom unmarshaler for the Sprite type

func (*Sprite) Update

func (s *Sprite) Update()

Update clears any change flags used in rendering

type SpriteSet

type SpriteSet struct {
	Name     string    `json:"name"`
	Author   string    `json:"author"`
	Date     time.Time `json:"date"`
	Revision int       `json:"revision"`
	Sprites  []*Sprite `json:"sprites"`
	// contains filtered or unexported fields
}

SpriteSet represents one or more sprites belonging to a single set

func GetSprites

func GetSprites() *SpriteSet

GetSprites retrieves a list of all of the sprints in the current SpriteSet

func LoadSpriteSet

func LoadSpriteSet(path string, flag int) (ss *SpriteSet, err error)

LoadSpriteSet reads in a SpriteSet for a JSON file and decodes it

func (SpriteSet) Clone

func (ss SpriteSet) Clone(file *os.File) (next *SpriteSet)

Clone creates a deep copy of an existing SpriteSet for a new file

func (*SpriteSet) Close

func (ss *SpriteSet) Close()

Close lets go of the file for this sprite set

func (*SpriteSet) Describe

func (ss *SpriteSet) Describe()

Describe summarizes a SpriteSet according to its metadata

func (*SpriteSet) IsModified

func (ss *SpriteSet) IsModified() bool

IsModified checks if any fo the sprites have been modified

func (*SpriteSet) Save

func (ss *SpriteSet) Save() error

Save writes out a SpriteSet to the file it was read from

func (*SpriteSet) SetPalette

func (ss *SpriteSet) SetPalette(p *Palette)

SetPalette sets the color Palette for this SpriteSet

func (*SpriteSet) Update

func (ss *SpriteSet) Update() error

Update marks the SpriteSet as no longer being changed

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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