renderer

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 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 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 NewImageForImage

func NewImageForImage(im image.Image) *Image

NewImageForImage 使用image.Image 创建图片

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) ToBytes

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

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

func (*Image) ToImage

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

ToImage 转换为image.Image

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