spritenik

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2019 License: MIT Imports: 10 Imported by: 0

README

SpriteNik

GoDoc Widget Build Status codecov Go Report Card

Generates Sprite from Textures

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	InvalidSubFile = errors.New("invalid sub file")
)

Functions

func GenerateSprite

func GenerateSprite(textures []Texture, pixelRatio int, renderImage bool) (map[string]*TextureSprite, image.Image, error)

Types

type GrowingPacker

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

func (*GrowingPacker) Fit

func (p *GrowingPacker) Fit(blocks []*Node)

type Node

type Node struct {
	Key    string
	Width  int
	Height int
	X      int
	Y      int
	Used   bool
	Right  *Node
	Down   *Node
}

func NewNode

func NewNode(name string, width, height int) *Node

code and blog from https://github.com/jakesgordon/bin-packing

type StyleFile

type StyleFile struct {
	Type       string
	Ext        string
	PixelRatio int
}

openapi:strfmt filename

func ParseStyleFile

func ParseStyleFile(s string) (*StyleFile, error)

func (StyleFile) MarshalText

func (f StyleFile) MarshalText() (text []byte, err error)

func (StyleFile) String

func (f StyleFile) String() string

func (*StyleFile) UnmarshalText

func (f *StyleFile) UnmarshalText(text []byte) error

type Texture

type Texture interface {
	TextureName() string
	TextureWidth() int
	TextureHeight() int
	TexturePixelRatio() int
	TextureImage() image.Image
}

type TextureMeta

type TextureMeta struct {
	Name       string `json:"-"`
	Width      int    `json:"width"`
	Height     int    `json:"height"`
	PixelRatio int    `json:"pixelRatio"`
}

func (TextureMeta) ScaleTo

func (t TextureMeta) ScaleTo(pixelRatio int) *TextureMeta

func (TextureMeta) String

func (t TextureMeta) String() string

type TextureSprite

type TextureSprite struct {
	*TextureMeta
	X                 int          `json:"x"`
	Y                 int          `json:"y"`
	OriginTextureMeta *TextureMeta `json:"-"`
	Image             image.Image  `json:"-"`
}

func (TextureSprite) String

func (s TextureSprite) String() string

Jump to

Keyboard shortcuts

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