Total members 11893 |It is currently Tue Nov 05, 2024 6:36 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





DDA Line Drawing Algorithm implementation on MFC,
Code:

void DrawByDDA
(HDC hdc,int xs,int ys,int xe,int ye,COLORREF color)
{
int dx=xe-xs;
int dy=ye-ys;
SetPixel(hdc,xs,ys,color);
if(
abs(dx)>=abs(dy))
{
int x=xs,xincdx>0?1:-1;
double y=ys,yinc=(double)dy/dx*xinc;
while(
x!=xe)
{
x+=xinc;
y+=yinc;
SetPixel(hdc,x,round(y),color);
}
}
 
else
{
int y=ys,yincdy>0?1:-1;
double x=xs,xinc=(double)dx/dy*yinc;
while(
y!=ye)
{
x+=xinc;
y+=yinc;
SetPixel(hdc,round(x),y,color);
}
}




_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : DDA Line Drawing Algorithm
 Bresenham (midpoint) algorithm (integer DDA) drawing line     -  
 Line Midpoint algorithm (J2ME)     -  
 Circle direct drawing algorithm     -  
 Circle drawing using Polar based algorithm with C++     -  
 Reading a File Line by Line in php     -  
 Line Translation 2D     -  
 Line Rotation 2D     -  
 Line Styles in java     -  
 getting a full line input     -  
 read from command line     -  



Topic Tags

C++ Graphics
cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com