images

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2021 License: AGPL-3.0 Imports: 21 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 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 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) 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)

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)

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 使用默认字体并设置字体大小

Jump to

Keyboard shortcuts

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