Open RaXaR opened 6 years ago
The whole point of the bresenham algorithm is to operate on integers, because, back in the days, floats were too slow for graphics processing. Therefore, the fact that you had to use floats is a bit puzzling. It's been a while, but if I remember correctly I didn't have any off-by-one error. Do you have the same error running the JS version?
Sorry for the delay, and happy new year!
https://github.com/floriansimon1/bresenham/blob/60355a4626c655312da722799bc53b03e300cda9/index.js#L44
Hi I ported your JS implementation to another scripting language and ran into a vertical off-by-one error. Basically the pixel below the one I was clicking on would be filled. By chaging '>=' to '>' it solved the issue. Also, in the port I kept all variables in float, not sure why all of this worked, but it did. :)