renderer

package
v1.2.0-alpha Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2023 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package renderer 图片和卡片绘制api

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadFromPath

func ReadFromPath(path string) (image.Image, error)

ReadFromPath 读取路径为path 的图片

func Txt2Img

func Txt2Img(ctx *zero.Ctx, txt string)

Txt2Img 文字转图片并发送

Types

type Image

type Image struct {
	Canvas   *gg.Context
	FontByte []byte
}

Image 图片绘制

func NewImage

func NewImage(width, height int) *Image

NewImage 创建一个宽、高分别为width、height 的空白图片

func NewImageByImage

func NewImageByImage(im image.Image) *Image

NewImageByImage 使用image.Image 创建图片

func NewImageByPath

func NewImageByPath(path string) *Image

NewImageByPath 使用path下的图片创建图片

func (*Image) Blur

func (i *Image) Blur(delta float64) image.Image

Blur 绘制强度为delta 的高斯模糊

func (*Image) DrawBackground

func (i *Image) DrawBackground(path string) error

DrawBackground 绘制背景

func (*Image) DrawCopyright

func (i *Image) DrawCopyright(copyright string, point float64)

DrawCopyright 绘制底部信息

copyright: 绘制的文字 point: 字体大小

func (*Image) DrawImages

func (i *Image) DrawImages(imgs []*ImageWithXY) *Image

DrawImages 将imgs 绘制到Image 结构体上的指定坐标

func (*Image) Fillet

func (i *Image) Fillet(r float64) image.Image

Fillet 裁剪图片为圆角矩形

func (*Image) LoadFont

func (i *Image) LoadFont(fontPath string) error

LoadFont 加载字体

func (*Image) ParseFontFace

func (i *Image) ParseFontFace(point float64) error

ParseFontFace 使用Image.FontByte 字体,大小为point

func (*Image) ScaleByPercent

func (i *Image) ScaleByPercent(factor float64) *Image

ScaleByPercent 百分比缩放

func (*Image) ScaleToSize

func (i *Image) ScaleToSize(targetWidth, targetHeight int) *Image

ScaleToSize 缩放到指定宽高

func (*Image) ToBase64

func (i *Image) ToBase64() ([]byte, error)

ToBase64 转换图片为b64

func (*Image) ToBytes

func (i *Image) ToBytes() ([]byte, error)

ToBytes 将图片转换为最大为4MB, 编码质量为70 的jpeg []byte

func (*Image) ToImage

func (i *Image) ToImage() image.Image

ToImage 转换为image.Image

func (*Image) WithXY

func (i *Image) WithXY(x, y int) *ImageWithXY

WithXY 转换Imgage 为ImageWithXY

type ImageWithXY

type ImageWithXY struct {
	*Image
	X, Y int
}

ImageWithXY 含有坐标信息的图片

func NewImageWithXY

func NewImageWithXY(img *Image, x, y int) *ImageWithXY

NewImageWithXY 使用Image 创建位置在 (x, y) 的图片

Jump to

Keyboard shortcuts

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