/
svg-sandbox.html
211 lines (189 loc) · 6.76 KB
/
svg-sandbox.html
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<style>
svg .styled-circle {
fill: darkmagenta;
stroke: black;
stroke-width: 5;
}
svg .styled-line {
stroke: black;
}
svg .styled-path {
stroke: black;
fill: none;
}
svg .styled-text {
fill: lightgrey;
stroke: red;
font-family: "Comic Sans MS";
}
svg a {
fill: blue;
}
svg a:visited {
fill: purple;
}
svg a:hover {
text-decoration: underline;
}
svg .linecap-demo {
stroke: darkmagenta;
stroke-width: 5;
}
svg .dasharray-demo {
stroke: darkmagenta;
stroke-width: 3;
}
svg.stacked-elements text {
text-anchor: middle;
fill: lightgrey;
}
svg.stacked-elements rect {
fill: crimson;
opacity: 0.5;
}
svg .blue-group {
fill: blue;
stroke-width: 3;
}
svg .red-group {
fill: red;
stroke-width: 4;
font-weight: bold;
}
svg .green-group {
fill: green;
stroke-width: 2;
font-family: Arial;
fill-opacity: 0.5;
}
</style>
</head>
<body>
<p>SVG Sandbox</p>
<svg width="500px" height="500px">
<circle cx="100" cy="150" r="20" class="styled-circle" />
<circle cx="15" cy="250" r="10" class="styled-circle" />
<circle cx="60" cy="300" r="50" class="styled-circle" />
<rect x="0" y="0" width="100" height="20" />
<rect x="175" y="10" width="80" height="30" rx="5" ry="2" />
<ellipse cx="250" cy="300" rx="10" ry="50" />
<polygon points="300,0 250,100 425,8" />
<line x1="300" y1="300" x2="450" y2="10" class="styled-line" />
<path d="M 0 50 q 50 -50 100 0 1 -100 0" class="styled-path" />
<!-- M is moveto, q is bezier curve -->
<text x="10" y="400" font-size="20" class="styled-text">SVG sandbox, now in SVG only</text>
</svg>
<svg width="500px" height="500px">
<text x="10" y="50" font-size="40" fill="grey">Anchors away! Or not...</text>
<circle cx="10" cy="50" r="4" fill="magenta" />
<line x1="10" y1="50" x2="420" y2="50" stroke="magenta" />
</svg>
<svg width="700px" height="500px">
<text x="10" y="20" text-anchor="start">This text is</text>
<text x="10" y="35" text-anchor="start">aligned</text>
<text x="10" y="50" text-anchor="start">to the start</text>
<text x="300" y="20" text-anchor="middle">This text is</text>
<text x="300" y="35" text-anchor="middle">aligned</text>
<text x="300" y="50" text-anchor="middle">to the middle</text>
<text x="590" y="20" text-anchor="end">This text is</text>
<text x="590" y="35" text-anchor="end">aligned</text>
<text x="590" y="50" text-anchor="end">to the end</text>
</svg>
<svg width="500px" height="500px">
<text x="10" y="20" class="styled-link" transform="rotate(30 20, 40)">Here's where to go to <a xlink:href="http://www.w3schools.com/svg/svg_text.asp">learn more about SVG text</a>, including how to rotate it</text>
</svg>
<svg width="500px" height="500px">
<circle cx="50" cy="50" r="20" fill="BlanchedAlmond" />
<circle cx="100" cy="50" r="20" stroke="#0000FF" stroke-width="5" fill="none" />
<circle cx="150" cy="50" r="20" fill="rgb(139,0,139)" />
<circle cx="50" cy="250" r="40" fill="rgb(0,0,255)" opacity="0.5" />
<circle cx="100" cy="250" r="40" fill="rgba(0,0,255,0.5)" />
</svg>
<svg width="500px" height="500px">
<text x="0" y="20" font-weight="bold">Linecaps</text>
<text x="0" y="50">Butt</text>
<line x1="60" y1="45" x2="200" y2="45" class="linecap-demo" stroke-linecap="butt" />
<text x="0" y="70">Round</text>
<line x1="60" y1="65" x2="200" y2="65" class="linecap-demo" stroke-linecap="round" />
<text x="0" y="90">Square</text>
<line x1="60" y1="85" x2="200" y2="85" class="linecap-demo" stroke-linecap="square" />
<text x="0" y="120" font-weight="bold">Dasharrays</text>
<text x="100" y="150" text-anchor="end">1 1</text>
<line x1="110" y1="145" x2="350" y2="145" class="dasharray-demo" stroke-dasharray="1 1" />
<text x="100" y="170" text-anchor="end">10 4 4 4</text>
<line x1="110" y1="165" x2="350" y2="165" class="dasharray-demo" stroke-dasharray="10 4 4 4" />
<text x="100" y="190" text-anchor="end">5 10 1 20 30 5</text>
<line x1="110" y1="185" x2="350" y2="185" class="dasharray-demo" stroke-dasharray="5 10 1 20 30 5" />
</svg>
<svg width="500px" height="500px" class="stacked-elements">
<text x="100" y="35">Text on the bottom</text>
<rect x="0" y="0" width="200" height="60" />
<rect x="250" y="0" width="200" height="60" />
<text x="350" y="35">Text on top</text>
</svg>
<svg width="700px" height="500px">
<g class="blue-group">
<text x="0" y="20">Blue group</text>
<rect x="0" y="40" width="50" height="50" rx="10" ry="10" />
<polygon points="80,30 70,70 130,50" />
<line x1="60" y1="75" x2="120" y2="90" stroke="blue" />
</g>
<g class="red-group">
<text x="200" y="20">Red group</text>
<rect x="200" y="40" width="50" height="50" rx="10" ry="10" />
<polygon points="280,30 270,70 330,50" />
<line x1="260" y1="75" x2="320" y2="90" stroke="red" />
</g>
<g class="green-group">
<text x="400" y="20">Green group</text>
<rect x="400" y="40" width="50" height="50" rx="10" ry="10" />
<polygon points="480,30 470,70 530,50" />
<line x1="460" y1="75" x2="520" y2="90" stroke="green" />
</g>
</svg>
<svg width="700px" height="500px">
<g class="blue-group">
<text x="0" y="20">Blue group</text>
<rect x="0" y="40" width="50" height="50" rx="10" ry="10" />
<polygon points="80,30 70,70 130,50" />
<line x1="60" y1="75" x2="120" y2="90" stroke="blue" />
</g>
<g class="red-group" transform="translate(200)">
<text x="0" y="20">Red group</text>
<rect x="0" y="40" width="50" height="50" rx="10" ry="10" />
<polygon points="80,30 70,70 130,50" />
<line x1="60" y1="75" x2="120" y2="90" stroke="red" />
</g>
<g class="green-group" transform="translate(400)">
<text x="0" y="20">Green group</text>
<rect x="0" y="40" width="50" height="50" rx="10" ry="10" />
<polygon points="80,30 70,70 130,50" />
<line x1="60" y1="75" x2="120" y2="90" stroke="green" />
</g>
</svg>
<svg width="700px" height="500px">
<g class="blue-group" transform="scale(1.2)">
<text x="0" y="20">Blue group</text>
<rect x="0" y="40" width="50" height="50" rx="10" ry="10" />
<polygon points="80,30 70,70 130,50" />
<line x1="60" y1="75" x2="120" y2="90" stroke="blue" />
</g>
<g class="red-group" transform="translate(200)">
<text x="0" y="20">Red group</text>
<rect x="0" y="40" width="50" height="50" rx="10" ry="10" />
<polygon points="80,30 70,70 130,50" />
<line x1="60" y1="75" x2="120" y2="90" stroke="red" />
</g>
<g class="green-group" transform="translate(200,120) rotate(90)">
<text x="0" y="20">Green group</text>
<rect x="0" y="40" width="50" height="50" rx="10" ry="10" />
<polygon points="80,30 70,70 130,50" />
<line x1="60" y1="75" x2="120" y2="90" stroke="green" />
</g>
</svg>
</body>
</html>