How do I draw a line?
You can use the Windows GDI to draw a line as DirectDraw doesn't provide a line drawing function. If you want to draw a line using DirectX then use Breshenham's Line Drawing Algorithm to draw lines by joining Pixels.The pseudocode to draw a line between (x1, y1) and (x2, y2)
a) Assume x=x1 and y=y1. Plot (x, y) Pixel
b) Find the largest among (x2-x1) and (y2-y1) (To find the line is predominant on which axis)
c) If(x2-x1) is the biggest (Line is predominant on X Axis)
{
Loop till x becomes x2
a. if (x2-x1) is positive then Increment x by 1
else Decrement x by 1
b. Find corresponding y as (int)((y2-y1)/(x2-x1))*x)
c. Plot (x, y) Pixel
}
else /* The line is Predominant on Y Axis */
{
Loop till y becomes y2
a. if (y2-y1) is positive then Increment y by 1
else Decrement y by 1
b. Find corresponding x as (int)((x2-x1)/(y2-y1))*y)
c. Plot (x, y) Pixel
}
FAQ Menu
Sponsored links
Build IT Knowledge with Current & Trusted Content
Helps Employees Develop & Hone New Technical Programming Skills. Sign Up & Get Full Access.
Helps Employees Develop & Hone New Technical Programming Skills. Sign Up & Get Full Access.
Check Out IT Certification Preparation Materials
Sign Up With SkillSoft & Get Access to Training Materials for Over 50 Professional Certifications.
Sign Up With SkillSoft & Get Access to Training Materials for Over 50 Professional Certifications.
Villanova University Six Sigma & IT Certificate Programs
100% Online programs in Six Sigma, IS Security, CISSP Prep, Business Analysis, Proj. Mgmt. and more!
100% Online programs in Six Sigma, IS Security, CISSP Prep, Business Analysis, Proj. Mgmt. and more!
3 Months Free - ASP.NET Web Hosting
3 Months Free & No Setup Fees on ASP.NET 3.5/2.0 Hosting on Windows 2008/2003 Servers ? Click Here!
3 Months Free & No Setup Fees on ASP.NET 3.5/2.0 Hosting on Windows 2008/2003 Servers ? Click Here!
SFTP components for .NET
Add complete SSH and SFTP support to your .NET framework application
Add complete SSH and SFTP support to your .NET framework application
