// Line draws a line between two points
Line draws a line between two points
// Line draws a line between two points
func Line(display drivers.Displayer, x0 int16, y0 int16, x1 int16, y1 int16, color color.RGBA) {
	if x0 == x1 {
		if y0 > y1 {
			y0, y1 = y1, y0
		}
		for ; y0 <= y1; y0++ {
			display.SetPixel(x0, y0, color)
		}
	} else if y0 == y1 {
		if x0 > x1 {
			x0, x1 = x1, x0
		}
		for ; x0 <= x1; x0++ {
			display.SetPixel(x0, y0, color)
		}
	} else { 
		dx := x1 - x0
		if dx < 0 {
			dx = -dx
		}
		dy := y1 - y0
		if dy < 0 {
			dy = -dy
		}
		steep := dy > dx
		if steep {
			x0, x1, y0, y1 = y0, y1, x0, x1
		}
		if x0 > x1 {
			x0, x1, y0, y1 = x1, x0, y1, y0
		}
		dx = x1 - x0
		dy = y1 - y0
		ystep := int16(1)
		if dy < 0 {
			dy = -dy
			ystep = -1
		}
		err := dx / 2
		for ; x0 <= x1; x0++ {
			if steep {
				display.SetPixel(y0, x0, color)
			} else {
				display.SetPixel(x0, y0, color)
			}
			err -= dy
			if err < 0 {
				y0 += ystep
				err += dx
			}
		}
	}
}
func Line ( display drivers . Displayer , x0 int16 , y0 int16 , x1 int16 , y1 int16 , color color . RGBA ) { if x0 == x1 { if y0 > y1 { y0 , y1 = y1 , y0 } for ; y0 <= y1 ; y0 ++ { display . SetPixel ( x0 , y0 , color ) } } else if y0 == y1 { if x0 > x1 { x0 , x1 = x1 , x0 } for ; x0 <= x1 ; x0 ++ { display . SetPixel ( x0 , y0 , color ) } } else { dx := x1 - x0 if dx < 0 { dx = - dx } dy := y1 - y0 if dy < 0 { dy = - dy } steep := dy > dx if steep { x0 , x1 , y0 , y1 = y0 , y1 , x0 , x1 } if x0 > x1 { x0 , x1 , y0 , y1 = x1 , x0 , y1 , y0 } dx = x1 - x0 dy = y1 - y0 ystep := int16 ( 1 ) if dy < 0 { dy = - dy ystep = - 1 } err := dx / 2 for ; x0 <= x1 ; x0 ++ { if steep { display . SetPixel ( y0 , x0 , color ) } else { display . SetPixel ( x0 , y0 , color ) } err -= dy if err < 0 { y0 += ystep err += dx } } } }
Line draws a line between two points
Line draws a line between two points
// Bresenham