Take another Bresenham loop and use it to modify the start and end position of original line in rectangular direction.

Problem is to efficently find the right starting point and not to draw any pixel twice (or skip a pixel) while drawing next line.

Working and tested C code is available from Github C code .

Here a test page including a few sample lines created by this code.

The black pixels are the starting points for the algorithm.

### Related Contents:

- Algorithm to detect intersection of two rectangles?
- Algorithm to fill triangle
- Precise subpixel line drawing algorithm (rasterization algorithm)
- Millions of 3D points: How to find the 10 of them closest to a given point?
- How to Compute OBB of Multiple Curves?
- I have an OpenGL Tessellated Sphere and I want to cut a cylindrical hole in it
- An algorithm to space out overlapping rectangles?
- Find if a point is inside a convex hull for a set of points without computing the hull itself
- Algorithm to return all combinations of k elements from n
- Why do we check up to the square root of a number to determine if the number is prime?
- Constant Amortized Time
- Counting inversions in an array
- What is stability in sorting algorithms and why is it important?
- Find largest rectangle containing only zeros in an N×N binary matrix
- Find a pair of elements from an array whose sum equals a given number
- Implement a queue in which push_rear(), pop_front() and get_min() are all constant time operations
- Difference between Big-O and Little-O Notation
- Diff Algorithm? [closed]
- Write a function that returns the longest palindrome in a given string
- How does finding a cycle start node in a cycle linked list work?
- Generate an integer that is not among four billion given ones
- How to get a square root for 32 bit input in one clock cycle only?
- Generating the partitions of a number
- Finding maximum for every window of size k in an array
- What algorithm for a tic-tac-toe game can I use to determine the “best move” for the AI?
- How can I compute a Cartesian product iteratively?
- Floating Point Divider Hardware Implementation Details
- Is there an efficient algorithm to generate a 2D concave hull?
- Best algorithm to test if a linked list has a cycle
- Efficient list intersection algorithm
- What algorithms compute directions from point A to point B on a map?
- What is the best way to get the minimum or maximum value from an Array of numbers?
- Argument for O(1) average-case complexity of heap insertion
- Two Rectangles intersection
- Find the missing and duplicate elements in an array in linear time and constant space
- O(nlogn) Algorithm – Find three evenly spaced ones within binary string
- Finding closest neighbour using optimized Levenshtein Algorithm
- reconstructing a tree from its preorder and postorder lists
- Algorithm to find two repeated numbers in an array, without sorting
- How to cartoon-ify an image programmatically?
- How to calculate or approximate the median of a list without storing the list
- Algorithm to list unique permutations of string with duplicate letters
- How do I check if a directed graph is acyclic?
- Basic Recursion, Check Balanced Parenthesis
- Time Complexity of two for loops [duplicate]
- The sieve of Eratosthenes in F#
- Iterating over a Binary Tree with O(1) Auxiliary Space
- Enumerating all paths in a directed acyclic graph
- Better shading on BW display while rendering filled surfaces
- Image Segmentation using Mean Shift explained