Documentation
¶
Index ¶
- Constants
- func Gen(text string, fd FontDrawer, fuzzers ...Fuzzer) draw.Image
- func GenBase64(text string, fd FontDrawer, fuzzers ...Fuzzer) (b64 string)
- func Inconsolata(ctx context.Context) func(string) draw.Image
- func Rotate(ctx context.Context, img draw.Image, deg int) draw.Image
- func Scale(ctx context.Context, img draw.Image, c float64) draw.Image
- type FontDrawer
- type FontVariant
- type FuzzFactory
- type Fuzzer
Constants ¶
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 ¶
Inconsolata draws text on img using the inconsolata font. ctx checks
- InconsolataVariant under FontVariantCtxKey key
Types ¶
type FontDrawer ¶
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 ¶
FuzzFactory helper closure that passes a (potentially) unique context to the Fuzzer.
type Fuzzer ¶
Fuzzer helper struct to call each fuzzer function with its own context.
func AccurateBands ¶
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 ConcentricCircles ¶
ConcentricCircles draws concentric rings over img.
func RandomCircles ¶
RandomCircles draws random grayscale circles over img. ctx reads noise key.
func RandomLines ¶
RandomLines draws random lines over img. ctx reads noise and color keys.