How to use Bresenham's line drawing algorithm with sub pixel bias?
<p><a href="https://en.wikipedia.org/wiki/Bresenham&#39;s_line_algorithm" rel="nofollow noreferrer">Bresenham's line drawing algorithm</a> is well known and quite simple to implement.</p>

<p>While there are more advanced ways to draw anti-ailesed lines, Im interested in writing a function which draws a single pixel width non anti-aliased line, based on floating point coordinates.</p>

<p>This means while the first and last pixels will remain the same, the pixels drawn between them will have a bias based on the sub-pixel position of both end-points.</p>

<p>In principle this shouldn't be all that complicated, since I assume its possible to use the sub-pixel offsets to calculate an initial <code>error</code> value to use when plotting the line, and all other parts of the algorithm remain the same.</p>

<blockquote>
  <p>No sub pixel offset:</p>
</blockquote>

<pre><code>X###
    ###X
</code></pre>

<p>Assuming the right hand point has a sub-pixel position close to the top, the line could look like this:</p>

<blockquote>
  <p>With sub pixel offset for example:</p>
</blockquote>

<pre><code>X######
       X
</code></pre>

<p>Is there a tried &amp; true method of drawing a line that takes sub-pixel coordinates into account?</p>

<hr>

<p>Note:</p>

<ul>
<li>This seems like a common operation, I've seen OpenGL drivers take this into account for example - using <code>GL_LINE</code>, though from a quick search I didn't find any answers online - maybe used wrong search terms?</li>
<li>At a glance this question looks like it might be a duplicate of:<br> <a href="https://stackoverflow.com/questions/24679963">Precise subpixel line drawing algorithm (rasterization algorithm)</a><br>However that is asking about drawing a wide line, this is asking about offsetting a single pixel line.</li>
<li>If there isn't some standard method, I'll try write this up to post as an answer.</li>
</ul>