I ran into special case where I need to produce ultra symmetrical line or ray in 2D grid in order from (x0, y0) through (x1, y1) like this:
void drawSymmetricalLine(int x0, int y0, int x1, int y1)
{
// loop and handle each (x, y)...
}
The actual problem lies in points where popular line drawing algorithms does NOT draw both coordinates (the other marked as x below) since it seems as thicken, which is desired in my case. Also performance is not important but simplicity.
Here is what I mean as ultra symmetrical lines:
ox ooo
oo ooo
o o
o o
o o
o
Explanation: Bresenham's line algorithm is a very efficient and accurate algorithm.
Given the starting and ending coordinates of a line, Bresenham Line Drawing Algorithm attempts to generate the points between the starting and ending coordinates.
You can probably use Bresenham's line algorithm and modify it slightly so when the step change to move the draw position from one row to another you paint both the before and after pixels on the y-axis for the current x-axis.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With