Browse Source

Make more stuff private

master 0.0.4
maze 12 months ago
parent
commit
4cf5d30d34
2 changed files with 18 additions and 18 deletions
  1. +1
    -1
      animation.go
  2. +17
    -17
      color.go

+ 1
- 1
animation.go View File

@ -166,7 +166,7 @@ func (a colorizedAnimation) colorize(i image.Image) image.Image {
return nil
}
if p, ok := i.(*image.Paletted); ok {
// log.Printf("colorize %T with %d colors", i, len(p.Palette))
// log.Printf("colorize %T with %d colors", i, len(p.Pin2DMDPalette))
return &image.Paletted{
Pix: p.Pix,
Stride: p.Stride,


+ 17
- 17
color.go View File

@ -12,14 +12,14 @@ import (
// Pin2DMDColoring contains a coloring description.
type Pin2DMDColoring struct {
Version uint8
Palette *Palette
Palettes []*Palette
Palette *Pin2DMDPalette
Palettes []*Pin2DMDPalette
Default int
Mappings map[uint32]*Mapping
Mappings map[uint32]*Pin2DMDMapping
Masks [][]byte
}
func (c *Pin2DMDColoring) GetPalette(i int) *Palette {
func (c *Pin2DMDColoring) GetPalette(i int) *Pin2DMDPalette {
if i < len(c.Palettes) {
return c.Palettes[i]
}
@ -35,9 +35,9 @@ func (c *Pin2DMDColoring) readPalettes(r io.Reader) (err error) {
return
}
// log.Printf("pal: reading %d palettes", palettes)
c.Palettes = make([]*Palette, palettes)
c.Palettes = make([]*Pin2DMDPalette, palettes)
for i := 0; i < int(palettes); i++ {
if c.Palettes[i], err = ReadPalette(r); err != nil {
if c.Palettes[i], err = readPin2DMDPalette(r); err != nil {
return
}
// log.Printf("palette %d: %d colors, default:%t persistent:%t", i, len(c.Palettes[i].Colors), c.Palettes[i].IsDefault, c.Palettes[i].IsPersistent)
@ -58,10 +58,10 @@ func (c *Pin2DMDColoring) readMappings(r io.Reader) (err error) {
return
}
// log.Printf("pal: reading %d mappings", mappings)
c.Mappings = make(map[uint32]*Mapping)
c.Mappings = make(map[uint32]*Pin2DMDMapping)
for i := 0; i < int(mappings); i++ {
var m *Mapping
if m, err = readMapping(r); err != nil {
var m *Pin2DMDMapping
if m, err = readPin2DMDMapping(r); err != nil {
return
}
c.Mappings[m.Checksum] = m
@ -91,7 +91,7 @@ func (c *Pin2DMDColoring) readMasks(r io.Reader) (err error) {
}
/*
func (c *Pin2DMDColoring) FindMapping(p *Plane, reverse bool) *Mapping {
func (c *Pin2DMDColoring) FindMapping(p *Plane, reverse bool) *Pin2DMDMapping {
s := checkSum(p.Data, reverse)
if m, ok := c.Mappings[s]; ok {
// Unmasked CRC matched.
@ -139,7 +139,7 @@ func DecodePin2DMDColoring(r io.Reader) (c *Pin2DMDColoring, err error) {
return c, nil
}
type Palette struct {
type Pin2DMDPalette struct {
Index uint16
Type uint8
IsDefault bool
@ -147,8 +147,8 @@ type Palette struct {
Colors color.Palette
}
func ReadPalette(r io.Reader) (p *Palette, err error) {
p = new(Palette)
func readPin2DMDPalette(r io.Reader) (p *Pin2DMDPalette, err error) {
p = new(Pin2DMDPalette)
if err = binary.Read(r, binary.BigEndian, &p.Index); err != nil {
return
}
@ -194,7 +194,7 @@ const (
SwitchModeFollow
)
type Mapping struct {
type Pin2DMDMapping struct {
Checksum uint32
Mode SwitchMode
PaletteIndex uint16
@ -202,8 +202,8 @@ type Mapping struct {
Offset uint32
}
func readMapping(r io.Reader) (m *Mapping, err error) {
m = new(Mapping)
func readPin2DMDMapping(r io.Reader) (m *Pin2DMDMapping, err error) {
m = new(Pin2DMDMapping)
if err = binary.Read(r, binary.BigEndian, &m.Checksum); err != nil {
return
}
@ -221,7 +221,7 @@ func readMapping(r io.Reader) (m *Mapping, err error) {
return m, err
}
func (m Mapping) IsAnimation() bool {
func (m Pin2DMDMapping) IsAnimation() bool {
switch m.Mode {
case SwitchModeReplace, SwitchModeColorMask, SwitchModeFollow:
return true


Loading…
Cancel
Save