-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
105 lines (90 loc) · 3.94 KB
/
main.go
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// English:
//
// This example was taken from https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/begin
//
// Português:
//
// Este exemplo foi retirado do site https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/begin
//
// <svg width="120" height="120" viewBox="0 0 120 120"
// xmlns="http://www.w3.org/2000/svg" version="1.1"
// xmlns:xlink="http://www.w3.org/1999/xlink">
//
// <!-- animated rectangles -->
// <rect x="10" y="35" height="15" width="0">
// <animate attributeType="XML" attributeName="width" from="0" to="100"
// begin="accessKey(s)" dur="8s"
// fill="freeze" />
// </rect>
//
// <!-- trigger -->
// <text x="60" y="80" text-anchor="middle"
// style="pointer-events:none;">Hit the "s" key</text>
//
// <!-- grid -->
// <text x="10" y="20" text-anchor="middle">0s</text>
// <line x1="10" y1="25" x2="10" y2="55" stroke="grey" stroke-width=".5" />
// <text x="35" y="20" text-anchor="middle">2s</text>
// <line x1="35" y1="25" x2="35" y2="55" stroke="grey" stroke-width=".5" />
// <text x="60" y="20" text-anchor="middle">4s</text>
// <line x1="60" y1="25" x2="60" y2="55" stroke="grey" stroke-width=".5" />
// <text x="85" y="20" text-anchor="middle">6s</text>
// <line x1="85" y1="25" x2="85" y2="55" stroke="grey" stroke-width=".5" />
// <text x="110" y="20" text-anchor="middle">8s</text>
// <line x1="110" y1="25" x2="110" y2="55" stroke="grey" stroke-width=".5" />
//
// <line x1="10" y1="30" x2="110" y2="30" stroke="grey" stroke-width=".5" />
// <line x1="10" y1="55" x2="110" y2="55" stroke="grey" stroke-width=".5" />
// </svg>
//go:build js
// +build js
// fixme: bug. https://lists.w3.org/Archives/Public/www-svg/2006Jan/0490.html
package main
import (
"github.com/helmutkemper/iotmaker.webassembly/browser/factoryBrowser"
"github.com/helmutkemper/iotmaker.webassembly/browser/html"
"github.com/helmutkemper/iotmaker.webassembly/platform/factoryColor"
"time"
)
func main() {
done := make(chan struct{}, 0)
stage := factoryBrowser.NewStage()
s1 := factoryBrowser.NewTagSvg().Width(120).Height(120).ViewBox([]float64{0, 0, 120, 120}).XmlnsXLink("http://www.w3.org/1999/xlink").Append(
// animated rectangles
factoryBrowser.NewTagSvgRect().X(10).Y(35).Height(15).Width(0).Append(
factoryBrowser.NewTagSvgAnimate().AttributeName("width").From(0).To(100).Begin("accessKey(s)").Dur(8*time.Second).Fill("freeze"),
),
// trigger
factoryBrowser.NewTagSvgText().X(60).Y(80).TextAnchor(html.KSvgTextAnchorMiddle).Style("pointer-events:none;").Text("Hit the \"s\" key"),
// grid
factoryBrowser.NewTagSvgText().X(10).Y(20).TextAnchor(html.KSvgTextAnchorMiddle).Text("0s"),
factoryBrowser.NewTagSvgLine().X1(10).Y1(25).X2(10).Y2(55).Stroke(factoryColor.NewGray()).StrokeWidth(0.5),
factoryBrowser.NewTagSvgText().X(35).Y(20).TextAnchor(html.KSvgTextAnchorMiddle).Text("2s"),
factoryBrowser.NewTagSvgLine().X1(35).Y1(25).X2(35).Y2(55).Stroke(factoryColor.NewGray()).StrokeWidth(0.5),
factoryBrowser.NewTagSvgText().X(60).Y(20).TextAnchor(html.KSvgTextAnchorMiddle).Text("4s"),
factoryBrowser.NewTagSvgLine().X1(60).Y1(25).X2(60).Y2(55).Stroke(factoryColor.NewGray()).StrokeWidth(0.5),
factoryBrowser.NewTagSvgText().X(85).Y(20).TextAnchor(html.KSvgTextAnchorMiddle).Text("6s"),
factoryBrowser.NewTagSvgLine().X1(85).Y1(25).X2(85).Y2(55).Stroke(factoryColor.NewGray()).StrokeWidth(0.5),
factoryBrowser.NewTagSvgText().X(110).Y(20).TextAnchor(html.KSvgTextAnchorMiddle).Text("8s"),
factoryBrowser.NewTagSvgLine().X1(110).Y1(25).X2(110).Y2(55).Stroke(factoryColor.NewGray()).StrokeWidth(0.5),
factoryBrowser.NewTagSvgLine().X1(10).Y1(30).X2(110).Y2(30).Stroke(factoryColor.NewGrey()).StrokeWidth(0.5),
factoryBrowser.NewTagSvgLine().X1(10).Y1(55).X2(110).Y2(55).Stroke(factoryColor.NewGrey()).StrokeWidth(0.5),
)
stage.Append(s1)
<-done
}
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//