Documentation
¶
Index ¶
- func CropJson2Image(jsonData string, config *Config, outputPath ...string) (string, error)
- func CropJson2ImageDefault(jsonData string, rules []string, outputPath ...string) (string, error)
- func Json2Image(jsonData string, config *Config, outputPath ...string) (string, error)
- func Json2ImageDefault(jsonData string, outputPath ...string) (string, error)
- func JsonCrop(input interface{}, rules []string) ([]byte, error)
- type ColorConfig
- type ColoredLine
- type Config
- func (c *Config) WithBackgroundColor(r, g, b float64) *Config
- func (c *Config) WithBraceLevelColors(colors [][3]float64) *Config
- func (c *Config) WithCropRules(rules ...string) *Config
- func (c *Config) WithCustomFont(fontPath string) *Config
- func (c *Config) WithDefaultTextColor(r, g, b float64) *Config
- func (c *Config) WithFont(fontType FontType) *Config
- func (c *Config) WithFontSize(size float64) *Config
- func (c *Config) WithLevelColors(colors [][3]float64) *Config
- func (c *Config) WithLineHeight(lineHeight float64) *Config
- func (c *Config) WithPadding(padding float64) *Config
- type FontConfig
- type FontType
- type ImageConfig
- type PathStep
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CropJson2Image ¶
CropJson2Image 将裁剪后的数据转换为图片
func CropJson2ImageDefault ¶ added in v0.0.3
CropJson2ImageDefault 使用默认配置将裁剪后的JSON转换为图片(向后兼容)
func Json2Image ¶
Json2Image 将JSON数据转换为图片 参数: - jsonData: JSON字符串 - config: 配置选项,如果为nil则使用默认配置 - outputPath: 输出路径(可选),如果不提供则返回base64字符串
func Json2ImageDefault ¶ added in v0.0.3
Json2ImageDefault 使用默认配置将JSON转换为图片(向后兼容)
Types ¶
type ColorConfig ¶ added in v0.0.3
type ColorConfig struct { LevelColors [][3]float64 // LevelColors 各层级的颜色 BraceLevelColors [][3]float64 // BraceLevelColors 括号的颜色 DefaultTextColor [3]float64 // DefaultTextColor 默认文本颜色 }
ColorConfig 颜色配置
type ColoredLine ¶
type ColoredLine struct {
// contains filtered or unexported fields
}
ColoredLine 带颜色信息的行
type Config ¶ added in v0.0.3
type Config struct { Font FontConfig // Font 字体配置 Image ImageConfig // Image 图片配置 Color ColorConfig // Color 颜色配置 CropRules []string // CropRules 裁剪规则 }
Config 配置选项
func (*Config) WithBackgroundColor ¶ added in v0.0.3
WithBackgroundColor 设置背景色
func (*Config) WithBraceLevelColors ¶ added in v0.0.3
WithBraceLevelColors 设置括号颜色
func (*Config) WithCropRules ¶ added in v0.0.3
WithCropRules 设置裁剪规则
func (*Config) WithCustomFont ¶ added in v0.0.3
WithCustomFont 设置自定义字体
func (*Config) WithDefaultTextColor ¶ added in v0.0.3
WithDefaultTextColor 设置默认文本颜色
func (*Config) WithFontSize ¶ added in v0.0.3
WithFontSize 设置字体大小
func (*Config) WithLevelColors ¶ added in v0.0.3
WithLevelColors 设置层级颜色
func (*Config) WithLineHeight ¶ added in v0.0.3
WithLineHeight 设置行高
func (*Config) WithPadding ¶ added in v0.0.3
WithPadding 设置内边距
type FontConfig ¶ added in v0.0.3
type FontConfig struct { Type FontType // Type 字体类型 CustomPath string // CustomPath 自定义字体文件路径(当Type为FontTypeCustom时使用) Size float64 // Size 字体大小 LineHeight float64 // LineHeight 行高 }
FontConfig 字体配置
type ImageConfig ¶ added in v0.0.3
type ImageConfig struct { Padding float64 // Padding 内边距 BackgroundColor [3]float64 // BackgroundColor 背景色 }
ImageConfig 图片配置
Click to show internal directories.
Click to hide internal directories.