Text
在图像中插入文字。
参数
参数名
类型
说明
label
string
文字内容
x
int
插入文字的左上角坐标的 x 轴
y
int
插入文字的左上角坐标的 y 轴
fontPath
string
字体文件路径
fontColor
color.Color
文字颜色
fontSize
float64
文字大小
dpi
float64
文字 DPI
返回值
*imgo.Image
类型的实例。
例子
package main
import (
"github.com/fishtailstudio/imgo"
"golang.org/x/image/colornames"
"image/color"
)
func main() {
fontPath := "/System/Library/Fonts/Supplemental/Arial.ttf"
imgo.Canvas(500, 500, color.White).
Text("Hello World", 50, 50, fontPath, colornames.Chocolate, 50, 100).
Save("out.png")
}
最后更新于