Documentation
¶
Index ¶
- func AdjustOpacity(m image.Image, percentage float64) image.Image
- func ClipImgToCircle(img image.Image) image.Image
- func GenQQListMsgWithAva(data map[int64]string, w float64, isUser bool) (msg message.MessageSegment, err error)
- func GenStringMsg(str string) message.MessageSegment
- func GetDefaultFont() *truetype.Font
- func GetNewTempSavePath(prefix string) (string, error)
- func MeasureStringDefault(str string, fontSize, lineSpace float64) (float64, float64)
- func ParseFont(path string) (*truetype.Font, error)
- type ImageCtx
- func NewImageCtx(w, h int) *ImageCtx
- func NewImageCtxWithBG(w, h int, bg image.Image, opacity float64) *ImageCtx
- func NewImageCtxWithBGColor(w, h int, c string) *ImageCtx
- func NewImageCtxWithBGPath(w, h int, bgPath string, opacity float64) (*ImageCtx, error)
- func NewImageCtxWithBGRGBA255(w, h int, r, g, b, a int) *ImageCtx
- func (img *ImageCtx) DrawStar(n int, x, y, r float64)
- func (img *ImageCtx) DrawStringWrapped(s string, x, y, ax, ay, width, lineSpacing float64, align gg.Align)
- func (img *ImageCtx) FillDonutChartDefault(title string, values []chart.Value) error
- func (img *ImageCtx) GenMessageAuto() (message.MessageSegment, error)
- func (img *ImageCtx) GenMessageBase64() (message.MessageSegment, error)
- func (img *ImageCtx) PasteLine(x1, y1, x2, y2, lineWidth float64, colorStr string)
- func (img *ImageCtx) PasteStringDefault(str string, fontSize, lineSpace float64, x, y, width float64) error
- func (img *ImageCtx) SaveTemp(prefix string) (string, error)
- func (img *ImageCtx) SaveTempDefault() (string, error)
- func (img *ImageCtx) SetColorAuto(colorStr string)
- func (img *ImageCtx) SetFont(font *truetype.Font, size float64) error
- func (img *ImageCtx) UseDefaultFont(size float64) error
- func (img *ImageCtx) WordWrap(s string, width float64) []string
- type Point
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AdjustOpacity ¶
AdjustOpacity 将输入图像m的透明度变为原来的倍数的图像返回。若原来为完成全不透明,则percentage = 0.5将变为半透明
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
GetDefaultFont 获取默认字体,若默认字体不存在,会自动寻找,但仍可能为nil
func GetNewTempSavePath ¶ added in v0.1.0
GetNewTempSavePath 获取新的临时图片可保存路径名(绝对路径)
func MeasureStringDefault ¶
MeasureStringDefault 测量str在默认情况(默认字体、分行)下的长宽
Types ¶
type ImageCtx ¶
ImageCtx 图片上下文
func NewImageCtxWithBG ¶
NewImageCtxWithBG 创建带有背景图片的图片上下文,通过opacity设置不透明度
func NewImageCtxWithBGColor ¶ added in v0.1.0
NewImageCtxWithBGColor 创建纯色背景的图片上下文
func NewImageCtxWithBGPath ¶
NewImageCtxWithBGPath 以背景图片路径创建带有背景图片的图片上下文
func NewImageCtxWithBGRGBA255 ¶
NewImageCtxWithBGRGBA255 以RGBA255形式创建纯色背景的图片上下文
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 (*ImageCtx) GenMessageAuto ¶
func (img *ImageCtx) GenMessageAuto() (message.MessageSegment, error)
GenMessageAuto 自动生成ZeroBot图片消息
func (*ImageCtx) GenMessageBase64 ¶
func (img *ImageCtx) GenMessageBase64() (message.MessageSegment, error)
func (*ImageCtx) PasteStringDefault ¶
func (img *ImageCtx) PasteStringDefault(str string, fontSize, lineSpace float64, x, y, width float64) error
PasteStringDefault 以默认方式(默认字体、黑色、Wrapped、左上角定位、文字居左)贴文字
func (*ImageCtx) SaveTempDefault ¶
SaveTempDefault 以默认前缀(tempimg)保存至临时图片文件夹
func (*ImageCtx) SetColorAuto ¶
SetColorAuto 根据参数自动识别并设置颜色
func (*ImageCtx) UseDefaultFont ¶
UseDefaultFont 使用默认字体并设置字体大小