Y
Hacker News
new
|
ask
|
show
|
jobs
by
amelius
782 days ago
What if you wanted to add the requirement that the user had to click on 1 specific piece of confetti?
2 comments
nicky0
782 days ago
Then you have a fun programming challenge.
link
MartijnHols
782 days ago
Add a click event listener to the body and overlay the event-coordinates on the canvas.
link
amelius
782 days ago
Will the canvas allow you to hit-test the confetti piece given the coordinate?
link
eyelidlessness
782 days ago
Canvas draws raster images, anything resembling an object in your drawing logic is already tracked separately by necessity. So regardless, you’d presumably check against whatever data model you’re using to determine what to draw.
link
lupire
782 days ago
By what time the user clicks, there's no reason for the program to
need
to remember what they drew where.
link
eyelidlessness
782 days ago
If that’s the case, what
other object
with coordinates would you reference on a canvas to determine whether it was clicked?
link