Copy link to clipboard
Copied
I am trying out canvas and can not see it in the live load or any browsers. here is the code.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<script>
window onload = function(){
var myCanvas = document.getElementById('myCanvas')
var ctx = myCanvas.getContext("2d");
ctx.beginPath();
ctx.arc(260,150,100,0, math PI*2, true);
ctx.closePath();
ctx.fill()l
}
</script>
</head>
<body>
<canvas id ="myCanvas" width="400" height="300" style="border:10px solid #000000;"></canvas>
</body>
</html>
I tried several different types in canvas. what is the problem?
thanks
jen
Have a look at
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<canvas id ="myCanvas" width="400" height="300" style="border:10px solid #000000;"></canvas>
<script>
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.beginPath();
ctx.arc(260,150,100,0, Math.PI*2);
ctx.fill();
</script>
</body>
</html>
Where I have used the correct syntax as in "Math.PI" and not made a typo by typing "l" instead of ";".
The main part of the solution is
...Copy link to clipboard
Copied
Is this an Animate CC question?
Create HTML5 Canvas documents in Animate CC
Copy link to clipboard
Copied
Have a look at
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<canvas id ="myCanvas" width="400" height="300" style="border:10px solid #000000;"></canvas>
<script>
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.beginPath();
ctx.arc(260,150,100,0, Math.PI*2);
ctx.fill();
</script>
</body>
</html>
Where I have used the correct syntax as in "Math.PI" and not made a typo by typing "l" instead of ";".
The main part of the solution is having the canvas drawn before the object that occupies it.