rendercard

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2022 License: GPL-3.0 Imports: 8 Imported by: 19

README

沃玛

RenderCard

Drawtitle

示例代码

  package main
     
  import (
      "github.com/Coloured-glaze/gg"
      "github.com/FloatTech/rendercard"
  )

  func main(){
      img, err = rendercard.Titleinfo{
          Line:          9,
          Lefttitle:     "服务列表",
          Leftsubtitle:  "service_list",
          Righttitle:    "FloatTech",
          Rightsubtitle: "ZeroBot-Plugin",
          Fontpath:      "/font.ttf",
          Imgpath:       "/kanban.png",
      }.Drawtitle()
      if err != nil {
        panic(err)
      }
      gg.SavePNG("/Drawtitle.png",img)
  }

示例图

服务列表

Drawtitledtext

示例代码

  package main
     
  import (
      "github.com/Coloured-glaze/gg"
      "github.com/FloatTech/rendercard"
  )

  func main(){
      textlist := []string{"文字描述1", "文字描述2", "文字描述3"}
      img, err = rendercard.Titleinfo{
          Lefttitle:     "名称"
          Leftsubtitle:  "简介"
          Righttitle:    "FloatTech",
          Rightsubtitle: "ZeroBot-Plugin",
          Imgpath:       "/kanban.png",
          Fontpath:      "/font.ttf",
          Fontpath2:     "/font2.ttf",
          Status:        true,
      }.Drawtitledtext(textlist)
      if err != nil {
        panic(err)
      }
      gg.SavePNG("/Drawtitledtext.png",img)
  }

示例图

Drawcard

示例代码

  package main
     
  import (
      "github.com/Coloured-glaze/gg"
      "github.com/FloatTech/rendercard"
  )

  func main(){
      img, err = rendercard.Titleinfo{
        Lefttitle:    "名称",				
        Leftsubtitle: "简介",
        Imgpath:      "/banner.png",
        Fontpath:     "/font.ttf",
        Fontpath2:    "/font2.ttf",
        Status:       true,
      }.Drawtitledtext()
      if err != nil {
        panic(err)
      }
      gg.SavePNG("/Drawcard.png",img)
  }

示例图

Documentation

Overview

Package rendercard ...

Index

Constants

View Source
const (
	// Imgwight 图像宽
	Imgwight = 1272.0
)

Variables

This section is empty.

Functions

func Fillet added in v0.0.2

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

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

func RenderText added in v0.0.2

func RenderText(text, font string, width, fontSize int) (txtPic image.Image, err error)

RenderText 文字转图片 width 是图片宽度

func Transparency added in v0.0.2

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

Transparency 更改透明度 magnification 倍率值

Types

type TextCardInfo added in v0.0.2

type TextCardInfo struct {
	// 卡片规格:宽度,默认600
	Width int
	// 卡片规格:高度,默认由Title+Text内容决定
	High int
	// 卡片规格:背景图
	Imgpath string
	// 标题字体
	FontOfTitle string
	// 正文的字体
	FontOfText string
	// 标题规格:标题内容
	Title string
	// 是否显示标题
	DisplayTitle bool
	// 标题规格:标题布局[Left|Center|Right],默认Left
	TitleSetting string
	// 正文规格:正文内容
	Text []string
	// 正文规格:正文要求
	//
	// true为每个元素按行显示,false按空格分割显示;
	TextSetting bool
}

TextCardInfo ...

func (TextCardInfo) DrawTextCard added in v0.0.2

func (g TextCardInfo) DrawTextCard() (imgForCard image.Image, err error)

DrawTextCard 绘制文字卡片

type Titleinfo

type Titleinfo struct {
	// 行数
	Line int
	// 左侧两行文本
	Lefttitle    string
	Leftsubtitle string
	// 右侧两行文本
	Righttitle    string
	Rightsubtitle string
	// 图片路径
	Imgpath string
	// 字体路径
	Fontpath  string
	Fontpath2 string
	// 状态
	Status bool
}

Titleinfo ...

func (Titleinfo) Drawcard

func (t Titleinfo) Drawcard() (imgs image.Image, err error)

Drawcard ...

func (Titleinfo) Drawtitle

func (t Titleinfo) Drawtitle() (imgs image.Image, err error)

Drawtitle ...

func (Titleinfo) Drawtitledtext

func (t Titleinfo) Drawtitledtext(info []string) (imgs image.Image, err error)

Drawtitledtext ...

Directories

Path Synopsis
Package color ...
Package color ...

Jump to

Keyboard shortcuts

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