drawtext

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddCenteredText

func AddCenteredText(s string, f font.Face, fg color.Color, canvas *Canvas)

AddCenteredText adds a centered text.

func BreakLines

func BreakLines(s string, f font.Face, canvas *Canvas) (lines []string, lineHeight float64)

BreakLines breaks s into one or more lines to make sure each part fits within the margins of canvas. It also returns the expected maximal line height.

func DrawGrid

func DrawGrid(canvas *Canvas, n int)

DrawGrid draws a grid on canvas. n gives the number of grid lines.

func ImageOf

func ImageOf(canvas *Canvas) image.Image

ImageOf returns the image given by canvas.

func MakeNewFontFace

func MakeNewFontFace(f *opentype.Font, size int) font.Face

MakeNewFontFace makes a new font face for writing.

func RenderCanvas

func RenderCanvas(canvas *Canvas, filetype string) []byte

RenderCanvas encodes the image of canvas. filetype is given as the extension ("png", "jpg"). Default filetype is "png".

func SetCursor

func SetCursor(canvas *Canvas, xpos, ypos float64)

SetCursor sets the position of the curser to xpos,ypos. The value should be between 0 and 1 representing the position relative to the printable size (canvas size minus the margins). (0,0) is top left, (1,1) is bottom right. And the cursor position represents the top left corner of the bounding box of next string to be written.

func WriteLine

func WriteLine(s string, align string, f font.Face, fg color.Color, canvas *Canvas)

WriteLine writes a new line containing s onto canvas using font face f and color fg. Align is "right", "left", or "center". Any other value for align will place the text at current cursor location.

Types

type Canvas

type Canvas struct {
	// contains filtered or unexported fields
}

Canvas holds information about the canvas on which to write text.

func NewCanvas

func NewCanvas(bg color.Color, width, height int) *Canvas

NewCanvas returns a new Canvas with margins set to 10% on each side, background color set to bg, and dimensions given by width and height.

Jump to

Keyboard shortcuts

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