language-icon Old Web
English
Sign In

Line drawing algorithm

A line drawing algorithm is a graphical algorithm for approximating a line segment on discrete graphical media. On discrete media, such as pixel-based displays and printers, line drawing requires such an approximation (in nontrivial cases). Basic algorithms rasterize lines in one color. A better representation with multiple color gradations requires an advanced process, spatial anti-aliasing. A line drawing algorithm is a graphical algorithm for approximating a line segment on discrete graphical media. On discrete media, such as pixel-based displays and printers, line drawing requires such an approximation (in nontrivial cases). Basic algorithms rasterize lines in one color. A better representation with multiple color gradations requires an advanced process, spatial anti-aliasing. On continuous media, by contrast, no algorithm is necessary to draw a line. For example, oscilloscopes use natural phenomena to draw lines and curves. The Cartesian slope-intercept equation for a straight line is Y = m x + b {displaystyle Y=mx+b} With m representing the slope of the line and b as the y intercept. Given that the two endpoints of the line segment are specified at positions ( x 1 , y 1 ) {displaystyle (x1,y1)} and ( x 2 , y 2 ) {displaystyle (x2,y2)} . we can determine values for the slope m and y intercept b with the following calculations, m = ( y 2 − y 1 ) / ( x 2 − x 1 ) {displaystyle m=(y2-y1)/(x2-x1)} so, b = y 1 − m . x 1 {displaystyle b=y1-m.x1} .

[ "Bresenham's line algorithm" ]
Parent Topic
Child Topic
    No Parent Topic