ogpgen

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

package ogpgen は OGP 画像を生成するパッケージです。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OgpImage

type OgpImage struct {
	Font            *truetype.Font
	BackgroundImage image.Image
	FontSize        float64
	FontColor       color.NRGBA
	TopMargin       int
	SideMargin      int
	LineSpace       int
}

OgpImage は OGP 画像生成に必要なフィールド等を定義した構造体です。

func NewOgpImage

func NewOgpImage(opt Option) (o *OgpImage, err error)

NewOgpImage は OgpImage のコンストラクタです。

func (*OgpImage) Draw

func (o *OgpImage) Draw(text string) (img *image.RGBA, err error)

Draw は OGP 画像のベース画像に指定された文字列 text を描画します。

type Option

type Option struct {
	FontPath            string
	FontSize            float64
	FontColor           string
	BackgroundImagePath string
	TopMargin           int
	SideMargin          int
	LineSpace           int
}

Option は NewOgpImage の引数を定義したコンストラクタです。 FontPath は OGP 画像に描画する文字列の TrueType フォントのパスを指定します。 FontSize は OGP 画像に描画する文字列のフォントサイズを指定します。 BackgroudImagePath は OGP 画像のベースになる jpeg 画像のパスを指定します。 TopMargin は 文字列描画時の上部のマージンを微調整したい場合に指定します。 SideMargin は 文字列描画時の左右のマージンを調整したい場合に指定します。 LineSpace は 文字列描画時の行間を調整したい場合に指定します。

Jump to

Keyboard shortcuts

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