Previous | Next --- Slide 46 of 62
Back to Lecture Thumbnails
mihirg

This struck me as a really interesting optimization but hard to parallelize — Kayvon talked in lecture about how scanning/performing an operation for every pixel would be expensive, but isn't this how GPU's draw these sorts of graphics?

perihare

You can still apply this optimization by breaking a line into multiple sub-segments, each of which then uses this iterative method of updating the current draw position.

MayaRamsey

Is this the way most modern drawing/photo editing software draws straight lines?

acb575

I found these slides to be helpful in explaining the algorithm mention above and the Bresenham algorithm - http://groups.csail.mit.edu/graphics/classes/6.837/F02/lectures/6.837-7_Line.pdf

@MayaRamsey - I don't think this is the way most modern drawing/photo editing software draw straight lines. This is because rounding is an expensive operation and this method deals with floating points. Bresenham algorithm is better than the naive algorithm mentioned above since it only uses integer arithmetic and is therefore faster. There are other algorithms (eg - https://en.wikipedia.org/wiki/Xiaolin_Wu's_line_algorithm) that do anti-aliasing to prevent jaggy lines, which are also better than the approach mentioned above.