My Profile
Active Members
TodayLast 7 Days
more...
Awards & Gifts
Online Exams
Fresher Jobs
Our fresher job section is exclusively for fresh graduates! Find jobs for freshers in major Indian
cities including Bangalore, Chennai, Hyderabad, Pune or Kochi
Resources
Find educational articles, blogs, discussion threads and other resources.
Colleges
Find details about any college in India or search for courses.
|
Line Drawing Algorithm - Bresenham
Posted Date: 12 Jun 2008 Resource Type: Articles/Knowledge Sharing Category: Computer & Technology
|
Posted By: Lenin Member Level: Diamond Rating: Points: 1
|
Line Drawing Algorithm - Bresenham
#include #include #include void main() { int gd = DETECT, gm; int dx, dy, p, end; float x1, x2, y1, y2, x, y; initgraph(&gd, &gm, "c:\tc\bgi"); printf("Enter Value of X1: "); scanf("%f", &x1); printf("Enter Value of Y1: "); scanf("%f", &y1); printf("Enter Value of X2: "); scanf("%f", &x2); printf("Enter Value of Y2: "); scanf("%f", &y2); dx = abs(x1 - x2); dy = abs(y1 - y2); p = 2 * dy - dx; if(x1 > x2) { x = x2; y = y2; end = x1; } else { x = x1; y = y1; end = x2; } putpixel(x, y, 10); while(x < end) { x = x + 1; if(p < 0) { p = p + 2 * dy; } else { y = y + 1; p = p + 2 * (dy - dx); } putpixel(x, y, 10); } getch(); closegraph(); }
|
Responses
|
No responses found. Be the first to respond and make money from revenue sharing program.
|
|
Watch TV Channels
|