-
Notifications
You must be signed in to change notification settings - Fork 1
/
manipulatesvg.html
43 lines (35 loc) · 1.07 KB
/
manipulatesvg.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
<!DOCTYPE html>
<html>
<head>
<script>
function render(){
// "circle" may be any tag name
triangle=document.getElementById("Render").getSVGDocument().lastChild;
rad=4;
count=0;
for(con=1;con<89;con++){
for(lab=1;lab<(90-con);lab++){
count++;
var shape = document.createElementNS("http://www.w3.org/2000/svg", "circle");
cx=(lab*(rad)*2)+con*(rad);
cy=con*(rad)*2*.866;
shape.setAttribute("cx", cx);
shape.setAttribute("cy", cy);
shape.setAttribute("r", 4);
shape.setAttribute("fill", "green");
// Add to a parent node; document.documentElement should be the root svg element.
// Acquiring a parent element with document.getElementById() would be safest.
triangle.appendChild(shape);
}
}
window.alert(count)
}
</script>
</head>
<body>
<h1>VoteGeek</h1>
<input value="Calculate" type="button" onclick="javascript:render()"/>
<br />
<EMBED ID="Render" SRC="empty.svg" width="780" height="650"><br />
</body>
</html>