images

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2022 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdjustOpacity

func AdjustOpacity(m image.Image, percentage float64) image.Image

AdjustOpacity 将输入图像m的透明度变为原来的倍数的图像返回。若原来为完成全不透明,则percentage = 0.5将变为半透明

func ClipImgToCircle

func ClipImgToCircle(img image.Image) image.Image

ClipImgToCircle 裁切图像成圆形

func GenQQListMsgWithAva

func GenQQListMsgWithAva(data map[int64]string, w float64, isUser bool) (msg message.MessageSegment, err error)

GenQQListMsgWithAva 生成带QQ头像的用户或群(以isUser参数区分)列表

func GenStringMsg added in v0.1.0

func GenStringMsg(str string) message.MessageSegment

GenStringMsg 以默认方式生成纯文字图片消息,若生成失败,则返回message.Text

func GetDefaultFont added in v0.1.0

func GetDefaultFont() *truetype.Font

GetDefaultFont 获取默认字体,若默认字体不存在,会自动寻找,但仍可能为nil

func GetNewTempSavePath added in v0.1.0

func GetNewTempSavePath(prefix string) (string, error)

GetNewTempSavePath 获取新的临时图片可保存路径名(绝对路径)

func MeasureStringDefault

func MeasureStringDefault(str string, fontSize, lineSpace float64) (float64, float64)

MeasureStringDefault 测量str在默认情况(默认字体、分行)下的长宽

func ParseFont

func ParseFont(path string) (*truetype.Font, error)

ParseFont 解析字体文件,生成truetype.Font结构

Types

type ImageCtx

type ImageCtx struct {
	*gg.Context
}

ImageCtx 图片上下文

func NewImageCtx

func NewImageCtx(w, h int) *ImageCtx

NewImageCtx 创建空图片上下文

func NewImageCtxWithBG

func NewImageCtxWithBG(w, h int, bg image.Image, opacity float64) *ImageCtx

NewImageCtxWithBG 创建带有背景图片的图片上下文,通过opacity设置不透明度

func NewImageCtxWithBGColor added in v0.1.0

func NewImageCtxWithBGColor(w, h int, c string) *ImageCtx

NewImageCtxWithBGColor 创建纯色背景的图片上下文

func NewImageCtxWithBGPath

func NewImageCtxWithBGPath(w, h int, bgPath string, opacity float64) (*ImageCtx, error)

NewImageCtxWithBGPath 以背景图片路径创建带有背景图片的图片上下文

func NewImageCtxWithBGRGBA255

func NewImageCtxWithBGRGBA255(w, h int, r, g, b, a int) *ImageCtx

NewImageCtxWithBGRGBA255 以RGBA255形式创建纯色背景的图片上下文

func (*ImageCtx) DrawStar added in v0.1.0

func (img *ImageCtx) DrawStar(n int, x, y, r float64)

DrawStar 绘制星星 n: 角数; (x, y): 圆心坐标; r: 圆半径

func (*ImageCtx) DrawStringWrapped added in v0.1.3

func (img *ImageCtx) DrawStringWrapped(s string, x, y, ax, ay, width, lineSpacing float64, align gg.Align)

DrawStringWrapped 重载gg的DrawStringWrapped,支持首尾空格和换行

func (*ImageCtx) FillDonutChartDefault added in v0.1.0

func (img *ImageCtx) FillDonutChartDefault(title string, values []chart.Value) error

func (*ImageCtx) GenMessageAuto

func (img *ImageCtx) GenMessageAuto() (message.MessageSegment, error)

GenMessageAuto 自动生成ZeroBot图片消息

func (*ImageCtx) GenMessageBase64

func (img *ImageCtx) GenMessageBase64() (message.MessageSegment, error)

func (*ImageCtx) PasteLine

func (img *ImageCtx) PasteLine(x1, y1, x2, y2, lineWidth float64, colorStr string)

PasteLine 画线

func (*ImageCtx) PasteStringDefault

func (img *ImageCtx) PasteStringDefault(str string, fontSize, lineSpace float64, x, y, width float64) error

PasteStringDefault 以默认方式(默认字体、黑色、Wrapped、左上角定位、文字居左)贴文字

func (*ImageCtx) SaveTemp

func (img *ImageCtx) SaveTemp(prefix string) (string, error)

SaveTemp 以前缀prefix保存至临时图片文件夹

func (*ImageCtx) SaveTempDefault

func (img *ImageCtx) SaveTempDefault() (string, error)

SaveTempDefault 以默认前缀(tempimg)保存至临时图片文件夹

func (*ImageCtx) SetColorAuto

func (img *ImageCtx) SetColorAuto(colorStr string)

SetColorAuto 根据参数自动识别并设置颜色

func (*ImageCtx) SetFont

func (img *ImageCtx) SetFont(font *truetype.Font, size float64) error

SetFont 通过truetype.Font设置字体与字体大小

func (*ImageCtx) UseDefaultFont

func (img *ImageCtx) UseDefaultFont(size float64) error

UseDefaultFont 使用默认字体并设置字体大小

func (*ImageCtx) WordWrap added in v0.1.3

func (img *ImageCtx) WordWrap(s string, width float64) []string

WordWrap 重载gg的WordWrap,支持首尾空格和换行

type Point added in v0.1.0

type Point struct {
	X, Y float64
}

Jump to

Keyboard shortcuts

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