vendredi 17 novembre 2017

Javascript Draw

Your browser does not support the canvas element.



<canvas id="myCanvas" width="400" height="400" style="border:1px solid #c0c0c0;">Your browser does not support the canvas element.</canvas><br><br>

<script>

for (var i = 0; i < 150; i++) {

var x0 = Math.floor(200*Math.random());
var y0 = Math.floor(200*Math.random());
var w0 = Math.floor(200*Math.random());
var h0 = Math.floor(200*Math.random());
var l0 = Math.floor(5*Math.random());

var canvas = document.getElementById("myCanvas");
var ctx = canvas.getContext("2d");


var p = new Path2D("m "+x0+","+y0+"l"+w0+","+h0+"l-"+w0+",0z");
ctx.fillStyle = "rgba(232, 120, 0, 0.2)";
ctx.fill(p);

ctx.strokeStyle = "#FF0000";
ctx.lineWidth = l0;
ctx.strokeRect(x0,y0, w0,h0);
}
</script>