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

Commit 1fe15ff

Browse files
committed
add actual svg example
1 parent a94e89a commit 1fe15ff

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

svg.html

+12-3
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,27 @@
1313
var angle = (step * RADIANS_PER_STEP) % (2 * Math.PI);
1414
var x = RADIUS * Math.cos(angle) + 400;
1515
var y = RADIUS * Math.sin(angle) + 400;
16-
// ...
16+
circle.setAttribute('cx', x);
17+
circle.setAttribute('cy', y);
1718
}
1819

1920
document.addEventListener('DOMContentLoaded', function() {
2021
var svg_canvas = document.getElementById('svg_canvas');
2122

2223
// make circle clickable
2324
var circle = document.getElementById('moving_circle');
24-
// ...
25+
var clickNo = 1;
26+
circle.addEventListener('click', function(evt) {
27+
circle.setAttribute('fill', FILL_COLORS[clickNo % FILL_COLORS.length]);
28+
clickNo++;
29+
});
2530

2631
// animate circle
27-
// ...
32+
var step = 0;
33+
setInterval(function() {
34+
updateCircle(circle, step);
35+
step++;
36+
}, MS_PER_STEP);
2837
});
2938
</script>
3039
</head>

0 commit comments

Comments
 (0)