51 lines
918 B
HTML
51 lines
918 B
HTML
<html>
|
|
<body>
|
|
|
|
|
|
<svg id="mySVG" viewBox="0 0 1 1" style="width: 100%; height: 100%; border: 1px solid red">
|
|
|
|
</svg>
|
|
|
|
|
|
<script>
|
|
|
|
var numPoints = 20*1000;
|
|
var svg = document.getElementById("mySVG");
|
|
|
|
for (i=0; i < numPoints; i++){
|
|
|
|
var u = i / numPoints;
|
|
|
|
x = Math.random();
|
|
y = Math.random();
|
|
|
|
var svgns = "http://www.w3.org/2000/svg";
|
|
|
|
var shape = document.createElementNS(svgns, "circle");
|
|
shape.setAttributeNS(null, "cx", x);
|
|
shape.setAttributeNS(null, "cy", y);
|
|
shape.setAttributeNS(null, "r", 0.001);
|
|
shape.setAttributeNS(null, "fill", "green");
|
|
|
|
svg.appendChild(shape);
|
|
}
|
|
|
|
|
|
function loop(){
|
|
requestAnimationFrame(loop);
|
|
|
|
var width = svg.clientWidth;
|
|
var height = svg.clientHeight;
|
|
|
|
svg.viewBox.baseVal.width = 1;
|
|
svg.viewBox.baseVal.height = height / width;
|
|
|
|
//svg.setAttribute("viewbox","0 0 " + width + " " + height);
|
|
}
|
|
|
|
requestAnimationFrame(loop);
|
|
|
|
</script>
|
|
|
|
</body>
|
|
</html> |