Let's build something fun with HTML5 Canvas - #JavaScript30 8/30

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

I had so much fun learning about this. Learned about mouse and touch events, HTML5 canvas, boolean flags and HSL.

PalashMondal
Автор

At 9:30, I solved the one-continuous-line problem by simply writing on line 27:
lastX = e.offsetX; and lastY = e.offsetY;
( This is after ctx.beginPath(); and before ctx.moveTo(lastX, lastY); )
This seemed just as effective and much simpler than modifying the EventListener functions.

ThePolaris
Автор

This is awesome and super fun, thanks for making learning javascript so much fun!

erikhendin
Автор

Had so much fun learning from such a great man .thanks sir for every thing .love you ❣️❣️❣️

shoaibkhan
Автор

What about touch events for mobile? I tried adding an event listener with "touchstart" in place of "mousedown", changing "isDrawing" to "true", also added an event listener to "touchend" to change "isDrawing" to "false" to no avail

mattdudzik
Автор

Love your vids especially the react ones, sitting in south africa and coding. LOVIT!

armandjansevanrensburg
Автор

Thank you for the tutorials, that was fun and I learned quite a bit.

christinefredricksen
Автор

Awesome!

I decided to throw in an extra and when CTRL+Z is pressed, it clears the canvas, resizes the brush size and the color. :)

gshnoozer
Автор

I haven't used Canvas yet. Is it possible to overlay a canvas element on an image (or simply import an image to the canvas) to create various games? Word search, coloring book, etc.?

MotiviqueStudio
Автор

i am doing same code but doesn't work what's the problem?

saadshah
Автор

i've been wondering...
Why is

ctx.beginPath()
ctx.moveTo(e.ClientX, e.ClientY)
ctx.lineTo(e.offsetX, e.offsetY)
ctx.stroke();

not working.
I thought that with e.ClientX and Y, it would work and we wouldnt be forced to uptade our position, but it doesnt work.. instead of clear line, we have behavior we want but with dots instead of clear line.
For that matter, using *ctx.moveTo(e.PageX, e.PageY)* should have give us the result, yet it doesnt.

Ludo
Автор

This is really cool and fun!! Thank you!

michaelnugent
Автор

Hey Wes, could you explain the diference between all these properties of X and Y position and when to use it? (offsetX, pageX, layerX)

AndersonSousa
Автор

Why not just use e.clientX and e.clientY
why are we using lastY lastX and offsets?

janhorak
Автор

Hi, awesome video. I learn a lot from you. hehehehehehe

sweetteamcformerlymrterras
Автор

i want a range button and color picker...

wajidkhankhan
Автор

"Eventually everything just gonna be black" ... Well i came for some JS, aaaand JS i got..

arch
Автор

This was one fix that was bugging me on mouseenter events.

canvas.addEventListener('mouseenter', (e) => {
if (e.which === 1) isDrawing = true;
[lastX, lastY] = [e.offsetX, e.offsetY];
});

feelingeverfine
Автор

FIRST! I don't like empty spaces :(

Jorissoris
Автор

This one got me hot and bothered not gonna lie

sessonid
visit shbcf.ru