rendercard

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2023 License: GPL-3.0 Imports: 8 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 Fillet added in v0.0.2

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

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

func RandJPColor added in v0.0.4

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

RandJPColor 随机和风颜色

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(fontfile string, texts []string, maxW, fontsize float64) ([]string, 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
	// TitleFont 标题字体
	TitleFont string
	// TextFont 正文字体
	TextFont string
	// 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 (g *Card) DrawTextCard() (imgForCard image.Image, err error)

DrawTextCard 绘制文字卡片

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 标题字体路径
	TitleFont string
	// TextFont 正文字体路径
	TextFont string
	// OffsetX 文字X坐标偏移 向右为正方向
	OffsetX float64
	// OffsetX 文字Y坐标偏移 向下为正方向
	OffsetY 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 绘制标题正文

Jump to

Keyboard shortcuts

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