text

package
v0.0.0-...-7b48451 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2024 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package text provides functions for rendering basicfont.Face fonts to a an image.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Draw

func Draw(dst draw.Image, text string, col color.Color, fnt *basicfont.Face, dx, dy float64, words bool)

Draw draws the provided text to the destination in the provided color. Relative position of the text is specified by dx and dy which must be in the range [0, 1]. If words is true, text spanning lines will be broken at word boundaries where possible.

func KeepAspectRatio

func KeepAspectRatio(dst, src image.Image) image.Rectangle

KeepAspectRatio returns a draw rectangle that can be used in a call to a draw.Scaler to maintain the src aspect ratio in the dst image.

draw.BiLinear.Scale(dst, KeepAspectRatio(dst, src), src, src.Bounds(), op, opts)

func Size

func Size(bound image.Rectangle, fnt *basicfont.Face) (rows, cols int)

Size returns the size, in font rows and columns, of the bounding rectangle.

Types

type Outlined

type Outlined[T draw.Image] struct {
	Text       T
	Background T

	OutlineColor color.Color
}

Outlined is an image that renders a single pixel width outline around a drawing.

func (Outlined[T]) At

func (o Outlined[T]) At(x, y int) color.Color

func (Outlined[T]) Bounds

func (o Outlined[T]) Bounds() image.Rectangle

func (Outlined[T]) ColorModel

func (o Outlined[T]) ColorModel() color.Model

func (Outlined[T]) Set

func (o Outlined[T]) Set(x, y int, c color.Color)

type Shrink

type Shrink struct {
	draw.Image

	// Margin is the margin size in pixels.
	Margin int
}

Shrink reduces the bounds of an Image by a margin.

func (Shrink) Bounds

func (s Shrink) Bounds() image.Rectangle

Jump to

Keyboard shortcuts

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