barcode

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

Documentation

Overview

Package barcode is a component for rendering barcodes with customisable content and colour for both background and data channels.

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{"websiteURL": []string{"content"}} would indicate that
		the user specified variable "websiteURL" will fill the Content property.
	*/
	NamedPropertiesMap map[string][]string
	// Content is the data which will be encoded as a barcode.
	Content string
	// Type is the sort of barcode to encode, such as QR, PDF, or two of five.
	Type render.BarcodeType
	/*
		TopLeft is the coordinates of the top-left corner of the rendered barcode (including
		background) relative to the top-left corner of the canvas.
	*/
	TopLeft image.Point
	// Width is the width of the barcode (including background).
	Width int
	// Height is the height of the barcode (including background).
	Height int
	// DataColour is the colour which will fill the data channel.
	DataColour color.NRGBA
	// BackgroundColour is the colour which will fill the background channel.
	BackgroundColour color.NRGBA
	// Extra is additional information required by certain barcode types.
	Extra render.BarcodeExtraData
}

Component implements the Component interface for images.

func (Component) GetJSONFormat

func (component Component) GetJSONFormat() interface{}

GetJSONFormat returns the JSON structure of a barcode component.

func (Component) SetNamedProperties

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

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

func (Component) Write

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

Write draws a barcode on the canvas.

Jump to

Keyboard shortcuts

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