images

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 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 GenQQRankMsgWithValue added in v0.3.0

func GenQQRankMsgWithValue(title string, users []UserValue, unit string) (msg message.MessageSegment, err error)

GenQQRankMsgWithValue 生成默认样式用户排行榜,users中可不填nickname,无需任何其它操作

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 MergeImageFile added in v0.2.0

func MergeImageFile(background string, destFile string, srcFiles ...string) (finalErr error)

MergeImageFile 将src图片文件由上到下合并至dest,取最大图片的宽度,其它图片居中,背景色为background

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 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) FillUserRankDefault added in v0.3.0

func (img *ImageCtx) FillUserRankDefault(title string, users []UserValue, unit string) error

FillUserRankDefault 生成默认用户排名图,图片宽度请设为730,排行高度 = len(users)*(120)+65

func (*ImageCtx) GenMessageAuto

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

GenMessageAuto 自动生成ZeroBot图片消息

func (*ImageCtx) GenMessageBase64

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

func (*ImageCtx) PasteCircle added in v0.3.0

func (img *ImageCtx) PasteCircle(x, y, r float64, colorStr string)

PasteCircle 画圆

func (*ImageCtx) PasteLine

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

PasteLine 画线

func (*ImageCtx) PasteRectangle added in v0.2.1

func (img *ImageCtx) PasteRectangle(x, y, w, h float64, colorStr string)

PasteRectangle 画矩形

func (*ImageCtx) PasteRoundedRectangle added in v0.3.0

func (img *ImageCtx) PasteRoundedRectangle(x, y, w, h, r float64, colorStr string)

PasteRoundedRectangle 画圆角矩形

func (*ImageCtx) PasteStringDefault

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

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

func (*ImageCtx) PasteWatermark added in v0.3.2

func (img *ImageCtx) PasteWatermark(x, y, fontsize float64, color string)

PasteWatermark 绘制水印,右下角定位

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
}

type UserValue added in v0.3.0

type UserValue struct {
	ID       int64   // QQ号
	Nickname string  // 昵称
	Value    float64 // 数值

	FmtPrec int // 展示小数点后几位
}

Jump to

Keyboard shortcuts

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