Documentation
¶
Overview ¶
Package imagetemplate defines a template for drawing custom images from pre-defined components, and provides to tools to load and implement that template.
Index ¶
- type BaseColour
- type BaseImage
- type Builder
- type ComponentTemplate
- type ImageBuilder
- func (builder ImageBuilder) ApplyComponents() (Builder, error)
- func (builder ImageBuilder) GetCanvas() render.Canvas
- func (builder ImageBuilder) GetComponents() []render.Component
- func (builder ImageBuilder) GetNamedPropertiesList() render.NamedProperties
- func (builder ImageBuilder) LoadComponentsData(fileData []byte) (Builder, error)
- func (builder ImageBuilder) LoadComponentsFile(fileName string) (Builder, error)
- func (builder ImageBuilder) SetCanvas(newCanvas render.Canvas) Builder
- func (builder ImageBuilder) SetComponents(components []ToggleableComponent) Builder
- func (builder ImageBuilder) SetNamedProperties(properties render.NamedProperties) (Builder, error)
- func (builder ImageBuilder) WriteToBMP() ([]byte, error)
- type Template
- type ToggleableComponent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseColour ¶
type BaseColour struct {
Red string `json:"R"`
Green string `json:"G"`
Blue string `json:"B"`
Alpha string `json:"A"`
}
BaseColour is the template format of the base colour settings
type BaseImage ¶
type BaseImage struct {
FileName string `json:"fileName"`
Data string `json:"data"`
BaseColour BaseColour `json:"baseColour"`
BaseWidth string `json:"width"`
BaseHeight string `json:"height"`
}
BaseImage is the template format of the base image settings
type Builder ¶
type Builder interface {
GetCanvas() render.Canvas
SetCanvas(newCanvas render.Canvas) Builder
GetComponents() []render.Component
SetComponents(components []ToggleableComponent) Builder
GetNamedPropertiesList() render.NamedProperties
SetNamedProperties(properties render.NamedProperties) (Builder, error)
ApplyComponents() (Builder, error)
LoadComponentsFile(fileName string) (Builder, error)
LoadComponentsData(fileData []byte) (Builder, error)
WriteToBMP() ([]byte, error)
}
Builder manipulates Canvas objects and outputs to a bitmap
func LoadTemplate ¶
LoadTemplate takes a file path and returns a Builder constructed from the template file
type ComponentTemplate ¶
type ComponentTemplate struct {
Type string `json:"type"`
Conditional render.ComponentConditional `json:"conditional"`
Properties json.RawMessage `json:"properties"`
}
ComponentTemplate is a partial unmarshalled Component, with its properties left in raw form to be handled by each known type of Component.
type ImageBuilder ¶
type ImageBuilder struct {
Canvas render.Canvas
Components []ToggleableComponent
NamedProperties render.NamedProperties
// contains filtered or unexported fields
}
ImageBuilder uses golang's native Image package to implement the Builder interface
func NewBuilder ¶
func NewBuilder() ImageBuilder
NewBuilder generates a new ImageBuilder with an internal canvas of the specified width and height, and optionally the specified starting colour. No provided colour will result in defaults for Image.
func (ImageBuilder) ApplyComponents ¶
func (builder ImageBuilder) ApplyComponents() (Builder, error)
ApplyComponents iterates over the internal Component array, applying each in turn to the Canvas
func (ImageBuilder) GetCanvas ¶
func (builder ImageBuilder) GetCanvas() render.Canvas
GetCanvas returns the internal Canvas object
func (ImageBuilder) GetComponents ¶
func (builder ImageBuilder) GetComponents() []render.Component
GetComponents gets the internal Component array
func (ImageBuilder) GetNamedPropertiesList ¶
func (builder ImageBuilder) GetNamedPropertiesList() render.NamedProperties
GetNamedPropertiesList returns the list of named properties in the builder object
func (ImageBuilder) LoadComponentsData ¶
func (builder ImageBuilder) LoadComponentsData(fileData []byte) (Builder, error)
LoadComponentsData sets the internal component array based on the contents of the specified JSON data
func (ImageBuilder) LoadComponentsFile ¶
func (builder ImageBuilder) LoadComponentsFile(fileName string) (Builder, error)
LoadComponentsFile sets the internal Component array based on the contents of the specified JSON file
func (ImageBuilder) SetCanvas ¶
func (builder ImageBuilder) SetCanvas(newCanvas render.Canvas) Builder
SetCanvas sets the internal Canvas object
func (ImageBuilder) SetComponents ¶
func (builder ImageBuilder) SetComponents(components []ToggleableComponent) Builder
SetComponents sets the internal Component array
func (ImageBuilder) SetNamedProperties ¶
func (builder ImageBuilder) SetNamedProperties(properties render.NamedProperties) (Builder, error)
SetNamedProperties sets the values of names properties in all components and conditionals in the builder
func (ImageBuilder) WriteToBMP ¶
func (builder ImageBuilder) WriteToBMP() ([]byte, error)
WriteToBMP outputs the contents of the builder to a BMP byte array
type Template ¶
type Template struct {
BaseImage BaseImage `json:"baseImage"`
Components []ComponentTemplate `json:"components"`
}
Template is the format of the JSON file used as a template for building images. See samples.json for examples, each element in the samples array is a complete and valid template object.
type ToggleableComponent ¶
type ToggleableComponent struct {
Conditional render.ComponentConditional
Component render.Component
}
ToggleableComponent is a component with its conditional
Directories
¶
| Path | Synopsis |
|---|---|
|
components
|
|
|
internal
|
|
|
demo
command
|
|
|
filesystem
Package filesystem provides file system access
|
Package filesystem provides file system access |
|
Package render renders images onto a canvas.
|
Package render renders images onto a canvas. |