Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var HttpGet = http.Get
Functions ¶
This section is empty.
Types ¶
type BackgroundMaker ¶
type Context ¶
type Context interface { Image() image.Image DrawStringWrapped(s string, x, y, ax, ay, width, lineSpacing float64, align gg.Align) LoadFontFace(path string, points float64) error MeasureString(s string) (w, h float64) MeasureMultilineString(s string, lineSpacing float64) (w, h float64) SetColor(c color.Color) }
type ContextMaker ¶
var NewContext ContextMaker = func(i image.Image) Context { return gg.NewContextForImage(i) }
type FontFinder ¶ added in v0.3.1
var FindFont FontFinder = findfont.Find
type ImageEncoder ¶
var EncodeImage ImageEncoder = png.Encode
type ImageWriter ¶
var WriteImage ImageWriter = func(file string, i image.Image) error { f, err := os.Create(file) if err != nil { return err } err = EncodeImage(f, i) if err != nil { return err } return f.Close() }
type TextFitter ¶ added in v0.3.1
var FitText TextFitter = func(context Context, text, font string, width, height int) (float64, error) { var size float64 for size = 0; size < 1000; size += 1 { err := context.LoadFontFace(font, size) if err != nil { return 0, fmt.Errorf("failed to test font \"%s\" %.1f: %w", font, size, err) } w, h := context.MeasureMultilineString(text, 1) if w > float64(width) || h > float64(height) { return size - 1, nil } } return 1000, nil }
Click to show internal directories.
Click to hide internal directories.