Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
amelius
on April 25, 2024
|
parent
|
context
|
favorite
| on:
A useful front-end confetti animation library
What if you wanted to add the requirement that the user had to click on 1 specific piece of confetti?
nicky0
on April 25, 2024
|
next
[–]
Then you have a fun programming challenge.
MartijnHols
on April 25, 2024
|
prev
[–]
Add a click event listener to the body and overlay the event-coordinates on the canvas.
amelius
on April 25, 2024
|
parent
[–]
Will the canvas allow you to hit-test the confetti piece given the coordinate?
eyelidlessness
on April 25, 2024
|
root
|
parent
[–]
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.
lupire
on April 25, 2024
|
root
|
parent
[–]
By what time the user clicks, there's no reason for the program to
need
to remember what they drew where.
eyelidlessness
on April 26, 2024
|
root
|
parent
[–]
If that’s the case, what
other object
with coordinates would you reference on a canvas to determine whether it was clicked?
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: