Base canvas

This commit is contained in:
Clayton Voges 2022-01-04 23:06:19 +00:00
parent ead4964a7f
commit 9f5169bfc0
3 changed files with 44 additions and 0 deletions

12
index.html Normal file
View file

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head>
<link href="styles/style.css" rel="stylesheet">
</head>
<body>
<canvas id="inventory">
</canvas>
<script src="inventory.js"></script>
</body>
</html>

24
inventory.js Normal file
View file

@ -0,0 +1,24 @@
window.addEventListener('load', () => {
const canvas = document.querySelector('#inventory');
const ctx = canvas.getContext("2d");
reloadEvent(canvas, ctx);
});
function reloadEvent(x, y){
window.addEventListener('resize', () => {
resize(x, y);
});
}
function draw(x) {
x.strokeStyle = 'blue';
x.lineWidth = '5';
x.strokeRect(0, 0, window.innerWidth, window.innerHeight);
}
function resize(x, y){
x.height = window.innerHeight;
x.width = window.innerWidth;
draw(y);
}

8
styles/style.css Normal file
View file

@ -0,0 +1,8 @@
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
#inventory {
border: 1px solid #000000;
}