I'm playing around with height maps (bitmaps), trying to create some of my own in my game, and for that I need to implement some basic drawing methods. I've quickly realized that drawing straight lines isn't as basic as I thought.
It simple's if your points share an X or Y coordinate, or if they are aligned so you can draw a perfectly diagonal line. But in all other cases its trickier.
What algorithm do you use to determine what pixels need to be coloured for it to become a "straight" line ?
Answer
I think what you need is Bresenham's line algorithm.
From what I remember it is used to determine what point should be coloured, not how much each point should be coloured.
No comments:
Post a Comment