imagetemplate

package module
v3.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2019 License: MIT Imports: 10 Imported by: 0

README

Image Template

GoDoc Build Status Coverage Status Go Report Card

An image templating library for golang. Builder provides the templating engine, render provides the canvas, individual components provide the elements which can be templated and rendered. Component registration follows the pattern of built-in package "image", any package which implements the Component interface (found under render) and uses the RegisterComponent function during initialisation will be available for use.

Several default components are included, see their documentation as well as detailed usage guidelines for the template files and Builder in the documentation pages.

Installation

go get "github.com/LLKennedy/imagetemplate/v3"

Basic Usage

loader, props, err := imagetemplate.New().Load().FromFile("template.json")

// Check props here, set any discovered variables with real values

data, err := loader.Write().ToBMP(props)
err = ioutil.WriteFile("output.bmp", data, os.ModeExclusive)

Testing

On windows, the simplest way to test is to use the powershell script.

./test.ps1

To emulate the testing which occurs in build pipelines for linux and mac, run the following:

go test . ./components/... ./render/... ./scaffold/... ./internal/filesystem -race -coverprofile=coverage.out;

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LoadOptions

type LoadOptions interface {
	FromBuilder(builder scaffold.Builder) (Loader, render.NamedProperties, error)
	FromBytes(bytes []byte) (Loader, render.NamedProperties, error)
	FromFile(path string) (Loader, render.NamedProperties, error)
	FromJSON(raw json.RawMessage) (Loader, render.NamedProperties, error)
	FromReader(reader io.Reader) (Loader, render.NamedProperties, error)
}

LoadOptions chooses the input format for Loader

type Loader

type Loader interface {
	Load() LoadOptions
	Write() WriteOptions
}

Loader creates image builders from several input options and writes the finished product to several output formats.

func New

func New() Loader

New returns a new loader with the default file system

func NewUsing

func NewUsing(fs vfs.FileSystem) Loader

NewUsing returns a new loader using a specified vfs

type WriteOptions

type WriteOptions interface {
	ToBuilder(props render.NamedProperties) (scaffold.Builder, error)
	ToBMP(props render.NamedProperties) ([]byte, error)
	ToCanvas(props render.NamedProperties) (render.Canvas, error)
	ToImage(props render.NamedProperties) (image.Image, error)
	ToBMPReader(props render.NamedProperties) (io.Reader, error)
}

WriteOptions chooses the output format for Loader

Directories

Path Synopsis
components
examples
internal
Package render renders images onto a canvas.
Package render renders images onto a canvas.
Package scaffold defines a template for drawing custom images from pre-defined components, and provides to tools to load and implement that template.
Package scaffold defines a template for drawing custom images from pre-defined components, and provides to tools to load and implement that template.

Jump to

Keyboard shortcuts

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