~nskaggs/+junk/xenial-test

« back to all changes in this revision

Viewing changes to src/github.com/ajstarks/svgo/skewabc/skewabc.go

  • Committer: Nicholas Skaggs
  • Date: 2016-10-24 20:56:05 UTC
  • Revision ID: nicholas.skaggs@canonical.com-20161024205605-z8lta0uvuhtxwzwl
Initi with beta15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// skewabc - exercise the skew functions
 
2
// +build !appengine
 
3
 
 
4
package main
 
5
 
 
6
import (
 
7
    "fmt"
 
8
    "os"
 
9
 
 
10
    "github.com/ajstarks/svgo"
 
11
)
 
12
 
 
13
var (
 
14
    g      = svg.New(os.Stdout)
 
15
    width  = 500
 
16
    height = 500
 
17
)
 
18
 
 
19
func sky(x, y, w, h int, a float64, s string) {
 
20
    g.Gstyle(fmt.Sprintf("font-family:sans-serif;font-size:%dpx;text-anchor:middle", w/2))
 
21
    g.SkewY(a)
 
22
    g.Rect(x, y, w, h, `fill:black; fill-opacity:0.3`)
 
23
    g.Text(x+w/2, y+h/2, s, `fill:white;baseline-shift:-33%`)
 
24
    g.Gend()
 
25
    g.Gend()
 
26
}
 
27
 
 
28
func main() {
 
29
    g.Start(width, height)
 
30
    g.Title("Skew")
 
31
    g.Rect(0, 0, width, height, "fill:white")
 
32
    g.Grid(0, 0, width, height, 50, "stroke:lightblue")
 
33
    sky(100, 100, 100, 100, 30, "A")
 
34
    sky(200, 332, 100, 100, -30, "B")
 
35
    sky(300, -15, 100, 100, 30, "C")
 
36
    g.End()
 
37
}