Categorygithub.com/LgoLgo/cogen
modulepackage
0.1.1
Repository: https://github.com/lgolgo/cogen.git
Documentation: pkg.go.dev

# README

Cogen

Cogen is an automatic article cover generation tool, which can generate article covers according to requirements after configuring relevant options.

Installation

To install this package, you need to install Go and set your Go workspace first.

  1. You first need Go installed, then you can use the below Go command to install Cogen.
go get -u github.com/LgoLgo/cogen
  1. Import it in your code:
import "github.com/LgoLgo/cogen"

Example

package main

import "github.com/LgoLgo/cogen"

func main() {
	cogen.CoverGen(
		cogen.WithTitle("How to generate an article cover by golang"),
		cogen.WithImagePath("example/gopher.png"),
		cogen.WithFontFilePath("font/zads.ttf"),
		cogen.WithFontRGB([]int{0, 0, 0}),
		cogen.WithCoverRGB([]int{250, 235, 215}),
		cogen.WithFontSize(100),
	)
}

Output

result

Options

OptionDefaultDescription
TitleLgoLgoTitle sets article title.
SavingFileNameLgoLgoSavingFileName sets file name.
FontFilePathfont/syqh.ttfFontFilePath sets font file path. There are other fonts in the font folder. If you need to use them, just configure their paths.
ImagePathLgoLgo.pngImagePath sets image path. The image will appear on the left side of the cover.
CoverRGB[]int{47, 54, 66}CoverRGB sets cover's RGB255.
FontRGB[]int{238, 241, 247}FontRGB sets font's RGB255.
FontSize76FontSize sets font size.
DPI72DPI sets font's DPI.
LineSpacing1.1LineSpacing sets line spacing.
Width1343Width sets cover width.
ResizeWidth1000ResizeWidth sets image width.
MaxWordWidth660.0MaxWordWidth sets max word's width.
Height734Height sets height.
ResizeHeight500ResizeHeight sets image height.
X800.0X sets font's X coordinate.
AX0.5AX sets font's AX.
AnchoredX200AnchoredX sets image's X coordinate.
AnchoredAX0.5AnchoredAX set image's AX.
Y300.0Y sets font's Y coordinate.
AY0.6AY sets font's AY.
AnchoredY220AnchoredY sets image's Y coordinate.
AnchoredAY0.5AnchoredAY set image's AY.

License

This project is under the Apache License 2.0. See the LICENSE file for the full license text.

# Packages

No description provided by the author

# Functions

No description provided by the author
No description provided by the author
WithAnchoredAX sets image's AX.
WithAnchoredAY sets image's AY.
WithAnchoredX sets image's X coordinate.
WithAnchoredY sets image's Y coordinate.
WithAX sets font's AX.
WithAY sets font's AY.
WithCoverRGB sets cover's RGB255.
WithDPI sets font's DPI.
WithFontFilePath sets font file path.
WithFontRGB sets font's RGB255.
WithFontSize sets font's size.
WithHeight sets cover's height.
WithImagePath sets image path.
WithLineSpacing sets line spacing.
WithMaxWordWidth sets max word width.
WithResizeHeight sets image's height.
WithResizeWidth sets image's width.
WithSavingFileName sets title.
WithTitle sets title.
WithWidth sets cover's width.
WithX sets font's X coordinate.
WithY sets font's Y coordinate.

# Variables

OptionsDefault is the default options.

# Structs

Option is the only struct that can be used to set Options.
No description provided by the author