Computing.Net > Forums > Programming > bresenham line drawing algorithm

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

bresenham line drawing algorithm

Reply to Message Icon

Name: needhelpppp
Date: January 7, 2003 at 13:01:33 Pacific
OS: me
CPU/Ram: 1.2 gig 512k ddr
Comment:

i am attempting to make a triangle using bresenham line drawing algorithm, so far I have the cord for a line but it comes up with errors:
error C2449: found '{' at file scope (missing function header?)
error C2059: syntax error : '}'
Error executing cl.exe.
Casn anyone help me at least getting the line working and if possible tell me how i will then go on to complete the triangle. here is my code so far... i need to have it done by tonight if possible so im desperate it just refuses to work:

#include
#include

#include


int dx,dy;

int main();

{
public void lineBresenham(int x0, int y0, int x1, int y1, Color color) {
int pix = color.getRGB();
int dy = y1 - y0;
int dx = x1 - x0;
int stepx, stepy;
if (dy dy) {
int fraction = dy - (dx >> 1); // same as 2*dy - dx
while (x0 != x1) {
if (fraction >= 0) {
y0 += stepy;
fraction -= dx; // same as fraction -= 2*dx
}
x0 += stepx;
fraction += dy; // same as fraction -= 2*dy
raster.setPixel(pix, x0, y0);
}
} else {
int fraction = dx - (dy >> 1);
while (y0 != y1) {
if (fraction >= 0) {
x0 += stepx;
fraction -= dy;
}
y0 += stepy;
fraction += dx;
raster.setPixel(pix, x0, y0);
}
}
}
}



Sponsored Link
Ads by Google

Response Number 1
Name: kev
Date: January 7, 2003 at 17:45:15 Pacific
Reply:

Well, for starters, you shouldn't have a semicolon after the "int main()" line.

Kevin.


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: bresenham line drawing algorithm

Vectors? www.computing.net/answers/programming/vectors/345.html

drawing graphs in C www.computing.net/answers/programming/drawing-graphs-in-c/862.html

c++ graphics www.computing.net/answers/programming/c-graphics/2376.html