Answers for "js write on canvas"

4

javascritp canvas

//Creates a canvas and draws a circle
var canvas = document.body.appendChild(document.createElement("canvas"));
var ctx = canvas.getContext("2d");

ctx.beginPath();
ctx.arc(canvas.width / 2, canvas.height / 2, 50, 0, Math.PI * 2);
ctx.fillStyle = "red";
ctx.strokeStyle = "black";
ctx.stroke();
ctx.fill();
Posted by: Guest on May-14-2020
0

js draw canvas on canvas

<canvas id="canvas-1"></canvas>
<canvas id="canvas-2"></canvas>
<script>
  const canvas1 = document.getElementById("canvas-1");
  const canvas2 = document.getElementById("canvas-2");
  const ctx1 = canvas1.getContext("2d");
  const ctx2 = canvas2.getContext("2d");
  ctx1.fillStyle = "red";
  ctx1.fillRect(10, 10, canvas1.width - 20, canvas.height - 20);
  ctx2.drawImage(canvas1, 0, 0);
</script>
Posted by: Guest on January-10-2022

Code answers related to "Javascript"

Browse Popular Code Answers by Language