datetime

package
v3.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package datetime is a text-based time component with customisable content, size, colour, location and time format.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Component

type Component struct {
	/*
		NamedPropertiesMap maps user/application variables to properties of the component.
		This field is filled automatically by VerifyAndSetJSONData, then used in
		SetNamedProperties to determine whether a variable being passed in is relevant to this
		component.

		For example, map[string][]string{"expiry": []string{"time"}} would indicate that
		the user specified variable "expiry" will fill the Time property.
	*/
	NamedPropertiesMap map[string][]string
	// Time is the timestamp to render.
	Time *time.Time
	// TimeFormat is the format with which to parse a string-based time input.
	TimeFormat string
	// Start is the coordinates of the dot relative to the top-left corner of the canvas.
	Start image.Point
	// Size is the size of the text in points.
	Size float64
	// MaxWidth is the maximum number of horizontal pixels the dot can move before scaling text.
	MaxWidth int
	// cutils.TextAlignment aligns text to the left, right or centre.
	TextAlignment cutils.TextAlignment
	// Font is the typeface to use.
	Font *truetype.Font
	// Colour is the colour of the text.
	Colour color.NRGBA
	// contains filtered or unexported fields
}

Component implements the Component interface for datetime.

func (Component) GetJSONFormat

func (component Component) GetJSONFormat() interface{}

GetJSONFormat returns the JSON structure of a datetime component.

func (Component) SetNamedProperties

func (component Component) SetNamedProperties(properties render.NamedProperties) (render.Component, error)

SetNamedProperties processes the named properties and sets them into the datetime properties.

func (Component) VerifyAndSetJSONData

func (component Component) VerifyAndSetJSONData(data interface{}) (render.Component, render.NamedProperties, error)

VerifyAndSetJSONData processes the data parsed from JSON and uses it to set datetime properties and fill the named properties map.

func (Component) Write

func (component Component) Write(canvas render.Canvas) (c render.Canvas, err error)

Write draws datetime on the canvas.

Jump to

Keyboard shortcuts

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