File: html5logo.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 (37 lines) | stat: -rw-r--r-- 1,485 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
34
35
36
37
package main

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

func main() {
	// HTML5 logo data from 
	// "Understanding and Optimizing Web Graphics", Session 508, 
	// Dean Jackson, Apple WWDC 2011
	//
	// Draggable elements via Jeff Schiller's dragsvg Javascript library

	// shield
	var sx = []int{71, 30, 481, 440, 255}
	var sy = []int{460, 0, 0, 460, 512}
	// highlight
	var hx = []int{256, 405, 440, 256}
	var hy = []int{472, 431, 37, 37}
	// "five"
	var fx = []int{181, 176, 392, 393, 396, 397, 114, 115, 129, 325, 318, 256, 192, 188, 132, 139, 256, 371, 372, 385, 387, 371}
	var fy = []int{208, 150, 150, 138, 109, 94, 94, 109, 265, 265, 338, 355, 338, 293, 293, 382, 414, 382, 372, 223, 208, 208}

	canvas := svg.New(os.Stdout)
	width := 512
	height := 512

	// begin the document with the onload event, and namespace for dragging
	canvas.Start(width, height, `onload="initializeDraggableElements();"`, `xmlns:drag="http://www.codedread.com/dragsvg"`)
	canvas.Rect(0, 0, width, height)                                               // black background
	canvas.Script("application/javascript", "http://www.codedread.com/dragsvg.js") // reference the drag script
	canvas.Polygon(sx, sy, `drag:enable="true"`, canvas.RGB(227, 79, 38))          // draggable shield
	canvas.Polygon(hx, hy, `drag:enable="true"`, canvas.RGBA(255, 255, 255, 0.3))  // draggable highlight
	canvas.Polygon(fx, fy, `drag:enable="true"`, canvas.RGB(219, 219, 219))        // draggable five
	canvas.End()
}