~nskaggs/+junk/xenial-test

« back to all changes in this revision

Viewing changes to src/github.com/ajstarks/svgo/svgopher/svgopher.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
// svgopher - Go mascot remix
 
2
// +build !appengine
 
3
 
 
4
package main
 
5
 
 
6
import (
 
7
        "os"
 
8
 
 
9
        "github.com/ajstarks/svgo"
 
10
)
 
11
 
 
12
var (
 
13
        width  = 500
 
14
        height = 300
 
15
        canvas = svg.New(os.Stdout)
 
16
)
 
17
 
 
18
func background(v int) { canvas.Rect(0, 0, width, height, canvas.RGB(v, v, v)) }
 
19
 
 
20
func gordon(x, y, w, h int) {
 
21
 
 
22
        w10 := w / 10
 
23
        w12 := w / 12
 
24
        w2 := w / 2
 
25
        w3 := w / 3
 
26
        w8 := w / 8
 
27
        w6 := w / 6
 
28
        xw := x + w
 
29
        h23 := (h * 2) / 3
 
30
 
 
31
        blf := "fill:black"
 
32
        wf := "fill:white"
 
33
        nf := "fill:brown"
 
34
        brf := "fill:brown; fill-opacity:0.2"
 
35
        brb := "fill:rgb(210,161,161)"
 
36
 
 
37
        canvas.Gstyle("fill:none; stroke:none")
 
38
        canvas.Bezier(x, y+h, x, y+h, x+w2, y-h, x+w, y+h, brb)
 
39
        canvas.Roundrect(x, y+(h-1), w, h, 10, 10, brb)
 
40
        canvas.Circle(x, y+h, w12, brf) // left ear
 
41
        canvas.Circle(x, y+h, w12-10, nf)
 
42
 
 
43
        canvas.Circle(x+w, y+h, w12, brf) // right ear
 
44
        canvas.Circle(x+w, y+h, w12-10, nf)
 
45
 
 
46
        canvas.Circle(x+w3, y+h23, w/9, wf) // left eye
 
47
        canvas.Circle(x+w3+10, y+h23, w10-10, blf)
 
48
        canvas.Circle(x+w3+15, y+h23, 5, wf)
 
49
 
 
50
        canvas.Circle(xw-w3, y+h23, w/9, wf) // right eye
 
51
        canvas.Circle(xw-w3+10, y+h23, w10-10, blf)
 
52
        canvas.Circle(xw-(w3)+15, y+h23, 5, wf)
 
53
 
 
54
        canvas.Roundrect(x+w2-w8, y+h+30, w8, w6, 5, 5, wf) // left tooth
 
55
        canvas.Roundrect(x+w2, y+h+30, w8, w6, 5, 5, wf)    // right tooth
 
56
 
 
57
        canvas.Ellipse(x+(w2), y+h+30, w6, w12, nf)   // snout
 
58
        canvas.Ellipse(x+(w2), y+h+10, w10, w12, blf) // nose
 
59
 
 
60
        canvas.Gend()
 
61
}
 
62
 
 
63
func main() {
 
64
        canvas.Start(width, height)
 
65
        canvas.Title("SVG Gopher")
 
66
        background(255)
 
67
        canvas.Gtransform("translate(100, 100)")
 
68
        canvas.Gtransform("rotate(-30)")
 
69
        gordon(48, 48, 240, 72)
 
70
        canvas.Gend()
 
71
        canvas.Gend()
 
72
        canvas.Link("svgdef.svg", "SVG Spec & Usage")
 
73
        canvas.Text(90, 145, "SVG", "font-family:Calibri,sans-serif;font-size:80;fill:brown")
 
74
        canvas.LinkEnd()
 
75
        canvas.End()
 
76
}