<!doctype html>
<html>
<head>
<script>
function my_clicked(){
const canvas = document.getElementById("mycanvas");
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, 250, 250);
ctx.fillRect(0,0,10,canvas.height);
ctx.fillRect(0,0,canvas.width,10);
ctx.fillRect(0,canvas.height-10,canvas.width,10);
ctx.fillRect(canvas.width-10,0,canvas.width-10,canvas.height-10);
}
</script>
</head>
<body>
<canvas id="mycanvas" width="250" height="250"></canvas>
<br>
<input type="button" onclick="my_clicked()" value="обрамить канвас">
</body>
</html>
|