draw

package
v0.0.0-...-2b8b345 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FuzzColor1CtxKey context key for fuzzer functions color (image/color.RGBA).
	FuzzColor1CtxKey key = iota + 1
	// FuzzColor2CtxKey context key for a second color (image/color.RGBA).
	FuzzColor2CtxKey
	// FuzzNoiseCtxKey context key for fuzzer noise (float64).
	FuzzNoiseCtxKey
	// FuzzBandThicknessCtxKey context key for thickness of bands, in pixels (int).
	FuzzBandThicknessCtxKey
	// FuzzSlopeCtxKey context key for line slope. (float64)
	FuzzSlopeCtxKey
	// FontVariantCtxKey key to select one of the font variants. (InconsolataVariant)
	FontVariantCtxKey
	// LineBreak set the linebreak (int).
	LineBreak
	// ScaleBy value to scale fonts by (float64).
	ScaleBy
	// RotateBy degrees to rotate by. Ignored unless RandomRotation explicitly
	// set to false. (int)
	RotateBy
	// RandomRotation whether to apply a random rotation from -35 to 35 degrees. (bool)
	RandomRotation
	// BackgroundColor set the bacground color for mask image. (image/color.RGBA)
	BackgroundColor
)

Variables

This section is empty.

Functions

func Gen

func Gen(text string, fd FontDrawer, fuzzers ...Fuzzer) draw.Image

Gen returns an image/draw.Image the image with text in it.

func GenBase64

func GenBase64(text string, fd FontDrawer, fuzzers ...Fuzzer) (b64 string)

GenBase64 returns the base64 encoding of the image with text in it.

func Inconsolata

func Inconsolata(ctx context.Context) func(string) draw.Image

Inconsolata draws text on img using the inconsolata font. ctx checks

  • InconsolataVariant under FontVariantCtxKey key

func Rotate

func Rotate(ctx context.Context, img draw.Image, deg int) draw.Image

func Scale

func Scale(ctx context.Context, img draw.Image, c float64) draw.Image

Types

type FontDrawer

type FontDrawer func(string) draw.Image

FontDrawer is the functype that draws fonts into the image. It's expected to return the image to work in as the font determines the size.

type FontVariant

type FontVariant uint8
const (
	// VariantInconsolataGray grayscale.
	VariantInconsolataGray FontVariant = iota + 1
	// VariantInconsolataBlack black font on white background.
	VariantInconsolataBlack
	// VariantInconsolataInverted white font on black background.
	VariantInconsolataInverted
)

type FuzzFactory

type FuzzFactory func(ctx context.Context) Fuzzer

FuzzFactory helper closure that passes a (potentially) unique context to the Fuzzer.

type Fuzzer

type Fuzzer func(img draw.Image)

Fuzzer helper struct to call each fuzzer function with its own context.

func AccurateBands

func AccurateBands(ctx context.Context) Fuzzer

AccurateBands works just like Bands, but the thickness is on point. Is about 1.5x more CPU costly than Bands, and 75x more memory.

func Bands

func Bands(ctx context.Context) Fuzzer

Bands draws paralell bands along the image.

func ConcentricCircles

func ConcentricCircles(ctx context.Context) Fuzzer

ConcentricCircles draws concentric rings over img.

func RandomCircles

func RandomCircles(ctx context.Context) Fuzzer

RandomCircles draws random grayscale circles over img. ctx reads noise key.

func RandomLines

func RandomLines(ctx context.Context) Fuzzer

RandomLines draws random lines over img. ctx reads noise and color keys.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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