Documentation ¶
Overview ¶
Ref: https://blog.logrocket.com/working-with-go-images/ Ref: https://github.com/zdhxiong/mdclub/tree/master/src/Vendor
Package mdavatar generated by go-bindata.// sources: static/NotoSansSC-Regular.otf static/Roboto-Light.ttf
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 DefaultAvatarTextHandle(text string, enableAsianFontChar bool) string
- func MustAsset(name string) []byte
- func RestoreAsset(dir, name string) error
- func RestoreAssets(dir, name string) error
- type AvatarTextHandler
- type Config
- type Option
- func DisableAsianFontChar() Option
- func WithAsianFont(asianFont string) Option
- func WithAvatarSize(avatarSize int) Option
- func WithAvatarTextHandle(avatarTextHandle AvatarTextHandler) Option
- func WithBackground(background *image.RGBA) Option
- func WithColors(colors []color.RGBA) Option
- func WithLetterFont(letterFont string) Option
- func WithPadding(padding int) Option
Constants ¶
This section is empty.
Variables ¶
var DefaultColors = mdColors
DefaultColors colors on mdavatar default
var DefaultConfig = &Config{ avatarTextHandle: DefaultAvatarTextHandle, avatarSize: 256, colors: DefaultColors, letterFontContent: MustAsset("static/Roboto-Light.ttf"), asianFontContent: MustAsset("static/NotoSansSC-Regular.otf"), }
DefaultConfig config on mdavatar default can be used directly
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("nonexistent") 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 DefaultAvatarTextHandle ¶
DefaultAvatarTextHandle mdavatar default handler for avatar text
func MustAsset ¶
MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.
func RestoreAsset ¶
RestoreAsset restores an asset under the given directory
func RestoreAssets ¶
RestoreAssets restores an asset under the given directory recursively
Types ¶
type AvatarTextHandler ¶
AvatarTextHandler handle for avatar text allow custom !!! e.g:
text: laojianzi => L text: 老健仔 => L
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config on mdavatar build
type Option ¶
type Option func(*Config)
Option set field value for Config
func DisableAsianFontChar ¶
func DisableAsianFontChar() Option
DisableAsianFontChar set Config.enableAsianFontChar is false and reset Config.asianFont is empty
func WithAsianFont ¶
WithAsianFont with option for Config.asianFont field
func WithAvatarSize ¶
WithAvatarSize with option for Config.avatarSize field
func WithAvatarTextHandle ¶
func WithAvatarTextHandle(avatarTextHandle AvatarTextHandler) Option
WithAvatarTextHandle with option for Config.avatarTextHandle field
func WithBackground ¶
WithBackground with option for Config.background field
func WithColors ¶
WithColors with option for Config.colors field
func WithLetterFont ¶
WithLetterFont with option for Config.letterFont field
func WithPadding ¶
WithPadding with option for Config.padding field