restore public_html

This commit is contained in:
Josh Ashton
2023-05-09 22:14:56 -06:00
parent 65c68b90dc
commit 1e7af0b94b
98 changed files with 4952 additions and 27 deletions
+76
View File
@@ -0,0 +1,76 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>HTML5 Canvas</title>
<link rel="icon" href="https://fav.farm/🔥" />
</head>
<body>
<ul>
<li id="0" class="color">Red</li>
<li id="122" class="color">Green</li>
<li id="255" class="color">Blue</li>
</ul>
<canvas id="draw" width="800" height="800"></canvas>
<script>
let isDrawing = false;
let lastX = 0;
let lastY = 0;
const canvas = document.querySelector('#draw');
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
canvas.addEventListener('mousemove', draw);
canvas.addEventListener('mouseup', () => isDrawing = false);
canvas.addEventListener('mouseout', () => isDrawing = false);
canvas.addEventListener('mousedown', (e) => {
isDrawing = true;
[lastX, lastY] = [e.offsetX, e.offsetY];
});
const ctx = canvas.getContext('2d');
ctx.strokeStyle = '#BADA55';
ctx.lineJoin = 'round';
ctx.lineCap = 'round';
const buttons = document.querySelectorAll('.color');
buttons.forEach(button => button.addEventListener('click', updateColor));
function updateColor() {
ctx.strokeStyle = `hsl(${this.id}, 100%, 50%)`;
}
function draw(e) {
if(!isDrawing) return;
ctx.beginPath();
ctx.moveTo(lastX, lastY);
[lastX, lastY] = [e.offsetX, e.offsetY];
ctx.lineTo(lastX, lastY);
ctx.stroke();
}
</script>
<style>
html, body {
margin: 0;
}
ul {
display: inline-block;
list-style-type: none;
margin: 0;
padding: 0;
}
li {
float: left;
display: block;
padding: 5px;
border: 2px solid black;
}
</style>
</body>
</html>