rendercard

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2024 License: GPL-3.0 Imports: 12 Imported by: 17

README

沃玛

RenderCard

图标是微博_warma_评论区一位微博用户下所画的

时间过于久远已经找不到原作者了

示例代码详见各test

DrawTitle

服务列表

DrawTitleWithText

用法

DrawCard

服务

Documentation

Overview

Package rendercard 渲染卡片

Index

Constants

View Source
const (
	// DefaultWidth 默认宽度
	DefaultWidth = 1272.0
)

Variables

View Source
var (
	// ErrNilTextFont ...
	ErrNilTextFont = errors.New("nil TextFont")
	// ErrNilTitleFont ...
	ErrNilTitleFont = errors.New("nil TitleFont")
)

Functions

func DrawRankingCard added in v0.2.0

func DrawRankingCard(fontdata []byte, title string, rankinfo []*RankInfo) (img image.Image, err error)

DrawRankingCard ...

func DrawRoundShadowedRectangle added in v0.0.7

func DrawRoundShadowedRectangle(canvas *gg.Context, x, y, w, h, r, sr, sigma float64, ox, oy int, rectanglecolor, shadowcolor color.Color)

DrawRoundShadowedRectangle 绘制带阴影的圆角矩形

func DrawShadowedRectangle added in v0.0.7

func DrawShadowedRectangle(canvas *gg.Context, x, y, w, h, r, sigma float64, ox, oy int, shadowcolor color.Color)

DrawShadowedRectangle 绘制阴影

func DrawShadowedString added in v0.0.7

func DrawShadowedString(canvas *gg.Context, s string, fontdata []byte, x, y, point, sigma float64, ox, oy int, stringcolor, shadowcolor color.Color) (err error)

DrawShadowedString 绘制带阴影的文字

func DrawShadowedStringAnchored added in v0.0.7

func DrawShadowedStringAnchored(canvas *gg.Context, s string, fontdata []byte, x, y, point, sigma float64, ox, oy int, stringcolor, shadowcolor color.Color, ax, ay float64) (err error)

DrawShadowedStringAnchored 在锚点上绘制带阴影的文字

func Fillet added in v0.0.2

func Fillet(dst image.Image, r float64) image.Image

Fillet 将矩形图片裁切为圆角矩形

func RandJPColor added in v0.0.4

func RandJPColor() (r, g, b int)

RandJPColor 随机和风颜色

func RenderServerListLogo(fontdata []byte) (img image.Image, err error)

RenderServerListLogo ...

func RenderServerPic added in v0.1.0

func RenderServerPic(pluginlist []*PluginInfo, torussd, glowsd []byte, zbplogopath string, serverlistlogo image.Image) (img image.Image, err error)

RenderServerPic ...

func Transparency added in v0.0.2

func Transparency(dst image.Image, magnification float64) image.Image

Transparency 更改透明度 magnification 倍率值

func Truncate added in v0.0.4

func Truncate(fontdata []byte, texts []string, maxW, fontsize float64) (newtexts []string, err error)

Truncate 截断文字

Types

type Alignment added in v0.0.4

type Alignment uint8

Alignment 对齐规则

const (
	NilAlign    Alignment = iota // NilAlign ..
	AlignLeft                    // AlignLeft 左对齐
	AlignCenter                  // AlignCenter 居中对齐
	AlignRight                   // AlignRight 右对齐
)

type Card added in v0.0.4

type Card struct {
	// Width 宽度,默认600
	Width int
	// Height 高度,默认由Title+Text内容决定
	Height int
	// BackgroundImage 背景图
	BackgroundImage string
	// TitleFontData 标题字体数据
	TitleFontData []byte
	// TextFontData 正文字体数据
	TextFontData []byte
	// Title 标题内容
	Title string
	// CanTitleShown 是否显示标题
	CanTitleShown bool
	// IsTextSplitPerElement true为每个元素按行显示,false按空格分割显示;
	IsTextSplitPerElement bool
	// TitleAlign 标题布局[Left|Center|Right],默认Left
	TitleAlign Alignment
	// Text 正文内容
	Text []string
}

Card 卡片配置

func (*Card) DrawTextCard added in v0.0.4

func (c *Card) DrawTextCard() (imgForCard image.Image, err error)

DrawTextCard 绘制文字卡片

func (*Card) Sum64 added in v0.0.8

func (c *Card) Sum64() uint64

Sum64 struct 的摘要

type PluginInfo added in v0.1.1

type PluginInfo struct {
	Name   string
	Brief  string
	Status bool
}

PluginInfo ...

type RankInfo added in v0.2.0

type RankInfo struct {
	Avatar         image.Image
	TopLeftText    string
	BottomLeftText string
	RightText      string
}

RankInfo ...

type Title added in v0.0.4

type Title struct {
	// Line 行数
	Line int
	// IsEnabled 状态
	IsEnabled bool
	// LeftTitle 左侧标题
	LeftTitle string
	// LeftSubtitle 左侧副标题
	LeftSubtitle string
	// RightTitle 右侧标题
	RightTitle string
	// RightSubtitle 右侧副标题
	RightSubtitle string
	// ImagePath 图片路径
	ImagePath string
	// TitleFont 标题字体数据
	TitleFontData []byte
	// TextFont 正文字体数据
	TextFontData []byte
	// OffsetX 文字X坐标偏移 向右为正方向
	OffsetX float64
	// OffsetX 文字Y坐标偏移 向下为正方向
	OffsetY float64
	// TitleFontOffsetPoint 标题字体大小偏移
	TitleFontOffsetPoint float64
	// TextFontOffsetPoint 正文字体大小偏移
	TextFontOffsetPoint float64
}

Title 标题配置

func (*Title) DrawCard added in v0.0.4

func (t *Title) DrawCard() (imgs image.Image, err error)

DrawCard 绘制卡片

func (*Title) DrawTitle added in v0.0.4

func (t *Title) DrawTitle() (imgs image.Image, err error)

DrawTitle 绘制标题

func (*Title) DrawTitleWithText added in v0.0.4

func (t *Title) DrawTitleWithText(info []string) (imgs image.Image, err error)

DrawTitleWithText 绘制标题正文

func (*Title) Sum64 added in v0.0.8

func (t *Title) Sum64() uint64

Sum64 struct 的摘要

Jump to

Keyboard shortcuts

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