Documentation ¶
Index ¶
- Variables
- func Asset(name string) ([]byte, error)
- func AssetDir(name string) ([]string, error)
- func AssetInfo(name string) (os.FileInfo, error)
- func AssetNames() []string
- func FontDirs(dirs string) []string
- func MustAsset(name string) []byte
- func NewCommand(group, tag, instruction string, prio int, ffn flagSetFunc, cfn cmdFunc, ...) *command
- func RestoreAsset(dir, name string) error
- func RestoreAssets(dir, name string) error
- func ToColor(model, value string) color.Color
- func WriteText(cv canvas.Canvas, o *Options) string
- type AlphaS
- type BlendFunc
- type ColorRGB
- type Fonts
- func (f *Fonts) Get(k string) *truetype.Font
- func (f *Fonts) List() []string
- func (f *Fonts) Set(name string, ft *truetype.Font) bool
- func (f *Fonts) SetByte(name string, fb []byte) bool
- func (f *Fonts) SetDir(paths ...string) error
- func (f *Fonts) SetPath(name, path string) bool
- func (f *Fonts) TextFont(k string, height, lineHeight float64, a align, c color.Color, o float64, ...) *TextFont
- type Options
- type Position
- type RGBA164
- type ResampleFilter
- type Text
- type TextBox
- type TextFont
- type TextLocation
Constants ¶
This section is empty.
Variables ¶
var ( NearestNeighbor = canvas.NearestNeighbor Box = ResampleFilter{ "box", 0.5, func(x float64) float64 { if math.Abs(x) < 0.5 { return 1 } return 0 }, } Linear = canvas.Linear Gaussian = ResampleFilter{ "gaussian", 1.0, func(x float64) float64 { x = math.Abs(x) if x < 1.0 { exp := 2.0 x *= 2.0 y := math.Pow(0.5, math.Pow(x, exp)) base := math.Pow(0.5, math.Pow(2, exp)) return (y - base) / (1 - base) } return 0 }, } MitchellNetravali = ResampleFilter{ "mitchelnetravali", 2.0, func(x float64) float64 { b := 1.0 / 3 c := 1.0 / 3 var w [4]float64 x = math.Abs(x) if x < 1.0 { w[0] = 0 w[1] = 6 - 2*b w[2] = (-18 + 12*b + 6*c) * x * x w[3] = (12 - 9*b - 6*c) * x * x * x } else if x <= 2.0 { w[0] = 8*b + 24*c w[1] = (-12*b - 48*c) * x w[2] = (6*b + 30*c) * x * x w[3] = (-b - 6*c) * x * x * x } else { return 0 } return (w[0] + w[1] + w[2] + w[3]) / 6 }, } CatmullRom = ResampleFilter{ "catmullrom", 2.0, func(x float64) float64 { b := 0.0 c := 0.5 var w [4]float64 x = math.Abs(x) if x < 1.0 { w[0] = 0 w[1] = 6 - 2*b w[2] = (-18 + 12*b + 6*c) * x * x w[3] = (12 - 9*b - 6*c) * x * x * x } else if x <= 2.0 { w[0] = 8*b + 24*c w[1] = (-12*b - 48*c) * x w[2] = (6*b + 30*c) * x * x w[3] = (-b - 6*c) * x * x * x } else { return 0 } return (w[0] + w[1] + w[2] + w[3]) / 6 }, } Lanczos = ResampleFilter{ "lanczos", 3.0, func(x float64) float64 { x = math.Abs(x) if x == 0 { return 1.0 } else if x < 3.0 { return (3.0 * math.Sin(math.Pi*x) * math.Sin(math.Pi*(x/3.0))) / (math.Pi * math.Pi * x * x) } return 0.0 }, } Bartlett = ResampleFilter{ "bartlett", 3.0, func(x float64) float64 { x = math.Abs(x) if x < 3.0 { return sinc(x) * (3.0 - x) / 3.0 } return 0 }, } Hermite = ResampleFilter{ "hermite", 1.0, func(x float64) float64 { x = math.Abs(x) if x < 1.0 { return bcspline(x, 0.0, 0.0) } return 0 }, } BSpline = ResampleFilter{ "bspline", 2.0, func(x float64) float64 { x = math.Abs(x) if x < 2.0 { return bcspline(x, 1.0, 0.0) } return 0 }, } Hann = ResampleFilter{ "hann", 3.0, func(x float64) float64 { x = math.Abs(x) if x < 3.0 { return sinc(x) * (0.5 + 0.5*math.Cos(math.Pi*x/3.0)) } return 0 }, } Hamming = ResampleFilter{ "hamming", 3.0, func(x float64) float64 { x = math.Abs(x) if x < 3.0 { return sinc(x) * (0.54 + 0.46*math.Cos(math.Pi*x/3.0)) } return 0 }, } Blackman = ResampleFilter{ "blackman", 3.0, func(x float64) float64 { x = math.Abs(x) if x < 3.0 { return sinc(x) * (0.42 - 0.5*math.Cos(math.Pi*x/3.0+math.Pi) + 0.08*math.Cos(2.0*math.Pi*x/3.0)) } return 0 }, } Welch = ResampleFilter{ "welch", 3.0, func(x float64) float64 { x = math.Abs(x) if x < 3.0 { return sinc(x) * (1.0 - (x * x / 9.0)) } return 0 }, } Cosine = ResampleFilter{ "cosine", 3.0, func(x float64) float64 { x = math.Abs(x) if x < 3.0 { return sinc(x) * math.Cos((math.Pi/2.0)*(x/3.0)) } return 0 }, } ResampleFilters = []ResampleFilter{ NearestNeighbor, Box, Linear, Gaussian, MitchellNetravali, CatmullRom, Lanczos, Bartlett, Hermite, BSpline, Hann, Hamming, Blackman, Welch, Cosine, } )
var ( FontsHome string )
var Core cmdMap
A string key map of functions returning a flip.Command.
Functions ¶
func Asset ¶
Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.
func AssetDir ¶
AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:
data/ foo.txt img/ a.png b.png
then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.
func AssetInfo ¶
AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.
func MustAsset ¶
MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.
func NewCommand ¶
func RestoreAsset ¶
RestoreAsset restores an asset under the given directory
func RestoreAssets ¶
RestoreAssets restores an asset under the given directory recursively
Types ¶
type Fonts ¶
type Fonts struct {
// contains filtered or unexported fields
}
var LF *Fonts
local fonts
type Options ¶
A package level Options struct consisting of a logger and a data.Vector.
var CoreOptions *Options
A package level Options instance.
type Position ¶
type Position = canvas.BlendPosition
type ResampleFilter ¶
type ResampleFilter = canvas.ResampleFilter
type Text ¶
type Text struct { *TextBox *TextLocation *TextFont // contains filtered or unexported fields }
func OptionsToText ¶
Translates a set of Options to a Text instance.
func (*Text) DrawString ¶
func (*Text) DrawStringAnchored ¶
func (*Text) DrawStringWrapped ¶
type TextFont ¶
func (*TextFont) MeasureString ¶
type TextLocation ¶
type TextLocation struct {
X, Y float64
}
func NewTextLocation ¶
func NewTextLocation(x, y float64) *TextLocation
func (*TextLocation) Locate ¶
func (t *TextLocation) Locate() fixed.Point26_6
func (*TextLocation) Point ¶
func (t *TextLocation) Point() image.Point