html
html
1
2
3
4
5
6
7
8
9
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<canvas id="canvas"></canvas>
</body>
</html>
Enter to Rename, Shift+Enter to Preview
css
css
1
2
3
4
5
6
body {
margin:0;
}
canvas{
display:block;
}
Enter to Rename, Shift+Enter to Preview
js
js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
var canvas,ctx;
var wRatio= 0.9;
var hRatio= 0.9;
window.onload = function (){
canvas=document.getElementById("canvas");
var w = canvas.width = window.innerWidth * wRatio;
var h = canvas.height = window.innerHeight * hRatio;
ctx = canvas.getContext("2d");
//rectangle
ctx.fillStyle="#f00";
ctx.fillRect(0,0,w,h);
}
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run