<!DOCTYPE html>
<html>
<body>
<canvas id="myCanvas" width="300" height="300" style="border:1px solid #d3d3d3;">
</canvas>
<script>
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
var h = 300;
var w = 300;
for (var position = 0; position < 300;position++)
{
ctx.strokeStyle ="#"+((1<<24)*Math.random()|0).toString(16);
var offset = Math.floor(Math.random()*25);
ctx.strokeRect(position*5+offset,position*5+offset ,w,h);
w -= 10+offset;
h -= 10+offset;
}
</script>
</body>
</html>
|