sprite

package
v0.0.0-...-475bae7 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2016 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Contains Spriter struct to generate css sprite by scanning css file, generate updated css file. For standalone command line utility, see css/cmd/sprite package

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

type Service interface {
	// OpenImage opens image file as io.Reader, path is the relative path defined
	// in css. Spriter will close the io.Reader if it also implements io.Closer.
	OpenImage(path string) (io.Reader, error)

	// Create sprite image file return as io.Writer. Spriter will close the
	// io.Writer if it also implements io.Closer. path is relative to output css
	// file.
	CreateSpriteImage(path string) (io.Writer, error)
}

Service provide/isolate I/O interface of Spriter.

func NewFileService

func NewFileService(srcPaths []string, outPath string) Service

Create a Service work with file system.

srcPaths: Base path used to resolve image files referenced in css. Normally
it is the directory where src .css file is. Can be multiple path, if the
.img not exist in 1st path, search it in next path.
outPath: Base path used to resolve generated sprite image files. Normally
it is the diretory where out .css file is.

type Spriter

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

Generate css sprite image by scan .css file, generate updated .css file.

Image must use relative path, absolute path or other web site report as warning.

Only png file supported, ignore other image file format.

Image file name need to be in [Group].[Name].png format, images with the same group name will generate a sprite image [Group].png. Images without group name leave it untouched.

func New

func New(css string, service Service) *Spriter

Create Spriter.

css: css file content

func (*Spriter) Gen

func (s *Spriter) Gen() (css string, err error)

Do the generation, return translated css file content. Generated sprite image files are saved using Service interface.

Jump to

Keyboard shortcuts

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