File: skewabc.go

package info (click to toggle)
golang-github-ajstarks-svgo 2012-01-27-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 2,720 kB
  • sloc: xml: 80; makefile: 31; sh: 29
file content (33 lines) | stat: -rw-r--r-- 668 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package main

import (
	"fmt"
	"os"
    
	"github.com/ajstarks/svgo"
)

var (
	g      = svg.New(os.Stdout)
	width  = 500
	height = 500
)

func sky(x, y, w, h int, a float64, s string) {
	g.Gstyle(fmt.Sprintf("font-family:sans-serif;font-size:%dpx;text-anchor:middle", w/2))
	g.SkewY(a)
	g.Rect(x, y, w, h, `fill:black; fill-opacity:0.3`)
	g.Text(x+w/2, y+h/2, s, `fill:white;baseline-shift:-33%`)
	g.Gend()
	g.Gend()
}

func main() {
	g.Start(width, height)
	g.Rect(0, 0, width, height, "fill:white")
	g.Grid(0, 0, width, height, 50, "stroke:lightblue")
	sky(100, 100, 100, 100, 30, "A")
	sky(200, 332, 100, 100, -30, "B")
	sky(300, -15, 100, 100, 30, "C")
	g.End()
}