Debian Codegraph @

examples/text_rotation/main.go

raw symbols SCIP
1 package main
2
3 //go:generate go run main.go
4
5 import (
6 "os"
7
8 "github.com/wcharczuk/go-chart/v2"
9 "github.com/wcharczuk/go-chart/v2/drawing"
10 )
11
12 func main() {
13 f, _ := chart.GetDefaultFont()
14 r, _ := chart.PNG(1024, 1024)
15
16 chart.Draw.Text(r, "Test", 64, 64, chart.Style{
17 FontColor: drawing.ColorBlack,
18 FontSize: 18,
19 Font: f,
20 })
21
22 chart.Draw.Text(r, "Test", 64, 64, chart.Style{
23 FontColor: drawing.ColorBlack,
24 FontSize: 18,
25 Font: f,
26 TextRotationDegrees: 45.0,
27 })
28
29 tb := chart.Draw.MeasureText(r, "Test", chart.Style{
30 FontColor: drawing.ColorBlack,
31 FontSize: 18,
32 Font: f,
33 }).Shift(64, 64)
34
35 tbc := tb.Corners().Rotate(45)
36
37 chart.Draw.BoxCorners(r, tbc, chart.Style{
38 StrokeColor: drawing.ColorRed,
39 StrokeWidth: 2,
40 })
41
42 tbcb := tbc.Box()
43 chart.Draw.Box(r, tbcb, chart.Style{
44 StrokeColor: drawing.ColorBlue,
45 StrokeWidth: 2,
46 })
47
48 file, _ := os.Create("output.png")
49 defer file.Close()
50 r.Save(file)
51 }