Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Line drawing algorithm
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Antialiasing == The biggest issue of single color line drawing algorithms is that they lead to [[Jaggies|lines with a rough, jagged appearance]]. On devices capable of displaying multiple levels of brightness, this issue can be avoided through [[Spatial anti-aliasing| antialiasing]]. For this, lines are usually viewed in a two-dimensional form, generally as a rectangle with a desired thickness. To draw these lines, points lying near this rectangle have to be considered. === Gupta and Sproull algorithm === The [[Gupta-Sproull algorithm|Gupta-Sproull]] algorithm is based on [[Bresenham's line algorithm|Bresenham's]] line algorithm but adds [[Anti-aliasing|antialiasing]]. An optimized variant of the Gupta-Sproull algorithm can be written in pseudocode as follows: DrawLine(x1, x2, y1, y2) { x = x1; y = y1; dx = x2 β x1; dy = y2 β y1; d = 2 * dy β dx; // discriminator // Euclidean distance of point (x,y) from line (signed) D = 0; // Euclidean distance between points (x1, y1) and (x2, y2) length = sqrt(dx * dx + dy * dy); sin = dx / length; cos = dy / length; '''while''' (x <= x2) { IntensifyPixels(x, y β 1, D + cos); IntensifyPixels(x, y, D); IntensifyPixels(x, y + 1, D β cos); x = x + 1 '''if''' (d <= 0) { D = D + sin; d = d + 2 * dy; } '''else''' { D = D + sin β cos; d = d + 2 * (dy β dx); y = y + 1; } } } The IntensifyPixels(x,y,r) function takes a radial line transformation and sets the intensity of the pixel (x,y) with the value of a cubic polynomial that depends on the pixel's distance r from the line.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)