model

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Atlas

type Atlas struct {
	Name    string   `json:"name"`
	Size    Size     `json:"size"`
	Sprites []Sprite `json:"sprites"`
}

type AtlasInfo

type AtlasInfo struct {
	Meta    Meta    `json:"meta"`
	Atlases []Atlas `json:"atlases"`
}

type Bin

type Bin struct {
	Size
	PackedRects []Rect
	UsedArea    int
}

Bin represents a Bin with a width, height,and a list of rectangles have been packed.

func NewBin

func NewBin(w, h int, req []Rect) Bin

NewBin creates a new bin with the given width, height, and list of rectangles to be packed.

func (Bin) FillRate

func (b Bin) FillRate() float64

func (Bin) String

func (b Bin) String() string

type Meta

type Meta struct {
	Repo      string `json:"repo"`
	Format    string `json:"format"`
	Version   string `json:"version"`
	Timestamp string `json:"timestamp"`
}

type Point

type Point struct {
	X int `json:"x"`
	Y int `json:"y"`
}

func NewPoint

func NewPoint(x, y int) Point

type Rect

type Rect struct {
	Point
	Size
	Id        int  `json:"-"`
	IsRotated bool `json:"rotated,omitempty"`
}

Rect represents an immutable rectangle using value semantics.

func NewRect

func NewRect(x, y, w, h, id int) Rect

NewRect creates a new Rect value.

func NewRectByPosAndSize

func NewRectByPosAndSize(x, y, w, h int) Rect

func NewRectBySize

func NewRectBySize(w, h int) Rect

func NewRectBySizeAndId

func NewRectBySizeAndId(w, h, id int) Rect

func (Rect) Clone

func (r Rect) Clone() Rect

func (Rect) CloneWithPos

func (r Rect) CloneWithPos(x, y int) Rect

func (Rect) CloneWithSize

func (r Rect) CloneWithSize(w, h int) Rect

func (Rect) IsContainedIn

func (r Rect) IsContainedIn(rect Rect) bool

func (Rect) Rotated

func (r Rect) Rotated() Rect

func (Rect) String

func (r Rect) String() string

func (Rect) ToImageRect

func (r Rect) ToImageRect() image.Rectangle

type Size

type Size struct {
	W int `json:"w"`
	H int `json:"h"`
}

Size represents a size with width and height. The width and height must be positive.

func NewSize

func NewSize(w, h int) Size

func (Size) Area

func (s Size) Area() int

func (Size) Clone

func (s Size) Clone() Size

func (Size) PowerOfTwo

func (s Size) PowerOfTwo() Size

func (Size) Rotated

func (s Size) Rotated() Size

type Sprite

type Sprite struct {
	FileName    string `json:"filename"`
	Frame       Rect   `json:"frame"`
	SrcRect     Size   `json:"srcRect"`
	TrimmedRect Rect   `json:"trimmedRect,omitzero"`
	Rotated     bool   `json:"rotated"`
	Trimmed     bool   `json:"trimmed"`
}

func (Sprite) Clone

func (s Sprite) Clone() Sprite

Jump to

Keyboard shortcuts

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