rectangle

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: 6 Imported by: 0

Documentation

Overview

Package rectangle is a simple rectangle component with customisable size, colour and location.

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{"squareSize": []string{"width", "height"}} would
		indicate that the user specified variable "squareSize" will fill the Width and Height
		properties.
	*/
	NamedPropertiesMap map[string][]string
	/*
		TopLeft is the coordinates of the top-left corner of the rectangle relative to the
		top-left corner of the canvas.
	*/
	TopLeft image.Point
	// Width is the width of the rectangle.
	Width int
	// Height is the height of the rectangle.
	Height int
	// Colour is the colour of the rectangle.
	Colour color.NRGBA
}

Component implements the Component interface for rectangles.

func (Component) GetJSONFormat

func (component Component) GetJSONFormat() interface{}

GetJSONFormat returns the JSON structure of a rectangle component.

func (Component) SetNamedProperties

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

SetNamedProperties processes the named properties and sets them into the rectangle 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 rectangle properties and fill the named properties map.

func (Component) Write

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

Write draws a rectangle on the canvas.

Jump to

Keyboard shortcuts

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