Bresenham's Line Algorithm - Canvas Api

code taken from https://stackoverflow.com/a/50625904