Hacker News new | ask | show | jobs
by rjmunro 1179 days ago
Not just the color, if you resize the window all calculations are totally thrown off. Try it with his live demo page: https://www.onsclom.net/dvd-logo

To avoid that, I'd use percentage positioning and have all widths and heights from 0-100. This would mean it would move faster horizontally than vertically in a wide window, but that's probably OK.

1 comments

Making the simulated window square would not be OK because that makes the period after which the simulation repeats / number of possible states much much smaller. A large part popularity of the DVD logo comes from waiting for it to hit a corner which in the original requires two modulo to line up exactly - whith your modulo that condition is either impossible or happens all the time because the logo only bounces between two corners.
Only if it's vertical speed and horizontal speed are the same. If you make it travel slightly faster vertically, it's going to look more equal when stretched to 16:9, and it's not going to follow identical paths.