go-chart/examples/text_rotation/main.go
Zeni Kim cc8d36edd9
Some checks failed
Continuous Integration / Tests (push) Has been cancelled
update url
2024-10-27 21:52:38 -05:00

51 lines
986 B
Go

package main
//go:generate go run main.go
import (
"os"
"git.smarteching.com/zeni/go-chart/v2"
"git.smarteching.com/zeni/go-chart/v2/drawing"
)
func main() {
f, _ := chart.GetDefaultFont()
r, _ := chart.PNG(1024, 1024)
chart.Draw.Text(r, "Test", 64, 64, chart.Style{
FontColor: drawing.ColorBlack,
FontSize: 18,
Font: f,
})
chart.Draw.Text(r, "Test", 64, 64, chart.Style{
FontColor: drawing.ColorBlack,
FontSize: 18,
Font: f,
TextRotationDegrees: 45.0,
})
tb := chart.Draw.MeasureText(r, "Test", chart.Style{
FontColor: drawing.ColorBlack,
FontSize: 18,
Font: f,
}).Shift(64, 64)
tbc := tb.Corners().Rotate(45)
chart.Draw.BoxCorners(r, tbc, chart.Style{
StrokeColor: drawing.ColorRed,
StrokeWidth: 2,
})
tbcb := tbc.Box()
chart.Draw.Box(r, tbcb, chart.Style{
StrokeColor: drawing.ColorBlue,
StrokeWidth: 2,
})
file, _ := os.Create("output.png")
defer file.Close()
r.Save(file)
}