Answers for "canvas tag html5"

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

canvas tag html

//HTML
<canvas id="canv"></canvas>

//Javascript
var canvas = document.getElementById("canv");
canvas.width = canvas.height = 100;
var ctx = canvas.getContext("2d");
ctx.fillStyle = "red";
ctx.fillRect(10, 10, 80, 80);
Posted by: Guest on May-21-2020
3

javascript canvas

#this code creates a circle within a canvas that must be created in HTML
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.beginPath();
ctx.arc(95, 50, 40, 0, 2 * Math.PI);
ctx.stroke();
Posted by: Guest on April-03-2020

Browse Popular Code Answers by Language