--- t/example.cc~ 2020-02-24 14:44:49.787613251 +0200 +++ t/example.cc 2020-06-29 01:28:50.315006837 +0300 @@ -8,14 +8,14 @@ float begin, step; public: Slope() {} - Slope(float from, float to, int num_steps) + Slope(float from, float to, float num_steps) { float inv_step = 1.f / num_steps; begin = from; // Begin here step = (to - from) * inv_step; // Stepsize = (end-begin) / num_steps } - float get() const { return begin; } - void advance() { begin += step; } + float get() const { return begin; } + void advance(float n=1) { begin += step*n; } }; template> @@ -49,16 +49,18 @@ // Scanline function [&](int y, SlopeData& left, SlopeData& right) { - int x = left[0].get(), endx = right[0].get(); + float leftx = left[0].get(), endx = right[0].get(); + auto intleftx = std::floor(leftx+.5f), rounding_error = intleftx - leftx + .5f; // Number of steps = number of pixels on this scanline = endx-x std::array props; for(unsigned p=0; p