Created
March 9, 2014 10:40
-
-
Save peterhellberg/9445874 to your computer and use it in GitHub Desktop.
SVGo experiments using goplay
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Based on https://github.com/ajstarks/svgo/blob/master/android/android.go | |
package main | |
import ( | |
"fmt" | |
"os" | |
"github.com/ajstarks/svgo" | |
) | |
var ( | |
width = 320 | |
height = 320 | |
canvas = svg.New(os.Stdout) | |
) | |
const ( | |
orange = "rgb(255,149,0)" | |
green = "rgb(211,240,44)" | |
) | |
func background(r, g, b int) { | |
canvas.Rect(0, 0, width, height, canvas.RGB(r, g, b)) | |
} | |
func android(x, y int, fill string, opacity float64) { | |
var linestyle = []string{ | |
`stroke="` + fill + `"`, | |
`stroke-linecap="round"`, | |
`stroke-width="5"`} | |
globalstyle := fmt.Sprintf("fill:%s;opacity:%.2f", fill, opacity) | |
canvas.Gstyle(globalstyle) | |
canvas.Arc(x+30, y+70, 35, 35, 0, false, true, x+130, y+70) | |
canvas.Line(x+60, y+25, x+50, y+10, linestyle[0], linestyle[1], linestyle[2]) | |
canvas.Line(x+100, y+25, x+110, y+14, linestyle[0], linestyle[1], linestyle[2]) | |
canvas.Circle(x+68, y+42, 11, "fill:white") | |
canvas.Circle(x+100, y+45, 5, `fill="white"`) | |
canvas.Roundrect(x+30, y+75, 100, 90, 10, 10) | |
canvas.Rect(x+30, y+75, 100, 20) | |
canvas.Roundrect(x+5, y+80, 20, 70, 10, 10) | |
canvas.Roundrect(x+135, y+80, 20, 67, 10, 10) | |
canvas.Roundrect(x+50, y+150, 20, 50, 10, 10) | |
canvas.Roundrect(x+90, y+150, 20, 50, 10, 10) | |
canvas.Gend() | |
} | |
func main() { | |
canvas.Start(width, height) | |
background(255,252,208) | |
canvas.Rotate(9) | |
canvas.Scale(0.7) | |
android(40, 20, orange, 1) | |
canvas.Gend() | |
canvas.Gend() | |
canvas.Scale(1.1) | |
android(110, 80, green, 1) | |
canvas.Gend() | |
canvas.End() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment