Skip to content
This repository was archived by the owner on Apr 8, 2025. It is now read-only.

Commit a94e89a

Browse files
committed
add svg example
1 parent 13de5ff commit a94e89a

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

Diff for: svg.html

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<html>
2+
<head>
3+
<title>My First SVG</title>
4+
<script type="text/javascript">
5+
6+
var RADIANS_PER_STEP = Math.PI / 256;
7+
var RADIUS = 200;
8+
var MS_PER_STEP = 10;
9+
10+
var FILL_COLORS = ['red', 'blue', 'yellow', 'green', 'orange'];
11+
12+
function updateCircle(circle, step) {
13+
var angle = (step * RADIANS_PER_STEP) % (2 * Math.PI);
14+
var x = RADIUS * Math.cos(angle) + 400;
15+
var y = RADIUS * Math.sin(angle) + 400;
16+
// ...
17+
}
18+
19+
document.addEventListener('DOMContentLoaded', function() {
20+
var svg_canvas = document.getElementById('svg_canvas');
21+
22+
// make circle clickable
23+
var circle = document.getElementById('moving_circle');
24+
// ...
25+
26+
// animate circle
27+
// ...
28+
});
29+
</script>
30+
</head>
31+
<body>
32+
<svg width="800" height="800" style="border: solid black 1px" id="svg_canvas">
33+
<circle cx="400" cy="400" r="40" stroke="black" stroke-width="3" fill="red" id="moving_circle"/>
34+
</svg>
35+
</body>
36+
</html>

0 commit comments

Comments
 (0)