Documentation ¶
Overview ¶
Package pkg contains desprite's implementation.
It can be used independently from the desprite command.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrBadName = errors.New("filename is empty after sanitation")
ErrBadName is returned when a rule's calculated file name is empty.
var ErrNonQualified = errors.New("rule must be of type QualifiedRule")
ErrNonQualified is returned when trying to extract a part from a non 'qualified' type rule.
var ErrOutOfBounds = errors.New("rule leads outside of the sprite bounds")
ErrOutOfBounds is returned when a rule's rectangle is not contained by the sprite.
Functions ¶
func Crop ¶
Crop crops a Part's rect out of an image. If the Part's rect is out of the image bounds, an error is returned.
Types ¶
type InvalidRatioError ¶
type InvalidRatioError struct {
Ratio int
}
InvalidRatioError is the type of error returned when an image ratio is invalid (<=0).
func (*InvalidRatioError) Error ¶
func (e *InvalidRatioError) Error() string
type Part ¶
Part is a named rectangle inside a sprite. It is a sub-image "guess" based on a rectangle-fitting CSS rule.
func Distinct ¶
Distinct filters duplicate rectangles from an array of Parts (last entry wins). If consinderName is true, the Part's name is also considered in the comparison (allowing duplicate rects).
func Find ¶
Find inspects a CSS rule for all properties that usually point to a sprite (width, height, background position). It returns a sprite "Part" or any error making the rule ineligable.
func FindAll ¶
func FindAll(sheet *css.Stylesheet) []*Part
FindAll calls Find for every rule in the stylesheet. It returns all extracted Parts and ignores all errors.
type UnknownFormatError ¶
UnknownFormatError is the type of error returned when a declaration's value doesn't match a "useful" format.
func (*UnknownFormatError) Error ¶
func (e *UnknownFormatError) Error() string
type UnrectableError ¶
UnrectableError is the type of error returned when a rule's declarations are not enough to determine a rect.
func (*UnrectableError) Error ¶
func (e *UnrectableError) Error() string