package main // Draw a line using dumb func LineDumb(fb *Framebuffer, color uint, x0 uint, y0 uint, x1 uint, y1 uint) { var t float32 for t = 0; t < 1; t += 0.01 { // Very simple interpolation between x and y x := x0 + uint(float32(x1-x0)*t) y := y0 + uint(float32(y1-y0)*t) fb.Set(x, y, color) } } func LineDumb2(fb *Framebuffer, color uint, x0 uint, y0 uint, x1 uint, y1 uint) { for x := x0; x < x1; x++ { // For each pixel across, compute how far across we are and interpolate y t := float32(x-x0) / float32(x1-x0) y := uint(float32(y0)*(1-t) + float32(y1)*t) fb.Set(x, y, color) } }