basic project card and projects page setup

This commit is contained in:
Josh Ashton
2023-05-10 22:40:04 -06:00
parent 1e7af0b94b
commit 6d1099590e
108 changed files with 673 additions and 154 deletions
+36
View File
@@ -0,0 +1,36 @@
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();
}