Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
started HTML5 canvas work
  • Loading branch information
RELIAS\wcoleman committed Nov 1, 2017
commit 9c6a341df0baee4729312a9952d657e2a7ff4f06
21 changes: 21 additions & 0 deletions 08 - Fun with HTML5 Canvas/index-START.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,27 @@
<body>
<canvas id="draw" width="800" height="800"></canvas>
<script>
const canvas = document.querySelector('#draw');
const ctx = canvas.getContext('2d');
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
ctx.strokeStyle='#BADA55';
ctx.lineJoin = 'round';
ctx.lineCap = 'round';

let isDrawing = false;
let lastX = 0;
let lastY = 0;

function draw(e){
if(!isDrawing) return; // stop the function from running when they are not moused down
console.log(e);
};

canvas.addEventListener('mousemove', draw);
canvas.addEventListener('mousedown', () => isDrawing = true);
canvas.addEventListener('mouseup', () => isDrawing = false);
canvas.addEventListener('mouseout', () => isDrawing = false);
</script>

<style>
Expand Down