I highly recommend:
Computer Graphics: Principles and Practice in C (2nd Edition)
(Hardcover)
by James D. Foley, Andries van Dam, Steven K. Feiner, John F. Hughes
http://www.amazon.com/gp/product/0201848406/sr=1-5/qid=1156365643/ref=sr
_1_5/104-9508715-9934366?ie=UTF8&s=books
[New and used from $25...]
The basic things you might want to search the web for are Bresenham's
line and circle algorithms. After that, you'll probably want to find C
source for "Bezier Splines" when you want to make things besides lines,
circles, and simple geometric figures.
Enjoy,
Bill.
-----Original Message-----
From: On Behalf
Of PeterElliot
Sent: Tuesday, August 22, 2006 7:37 PM
To:
Subject: [ts-7000] Re: Frame Buffer Programming ? Solved - example
circle drawing program
Hi Eduardo,
Here's my current circle routine. I haven't optimized the
circlePlotPoints function as yet.. I can't remember where I found the
basic routine, but if I do I'll give them credit when I create my
library...
#define VGAxy(x,y) ((y<<9)+(y<<7)+x)
void circleMidpoint(int xCenter, int yCenter, int radius, int color);
void circleMidpoint(int xCenter, int yCenter, int radius, int color) {
int x = 0;
int y = radius;
int p = 1 - radius;
void circlePlotPoints(int xCenter, int yCenter, int x, int y,int
color);
/* Plot first set of points */
circlePlotPoints(xCenter, yCenter, x, y, color);
while (x < y) {
x++;
if (p<0) p+=(x << 1)+1;
else { y--; p += ((x-y)<<1) + 1; }
circlePlotPoints(xCenter, yCenter, x, y, color);
}
}
void circlePlotPoints(int xCenter, int yCenter, int x, int y, int
color){
int Adr,x2,y2;
x2=(x<<1);
y2=(y<<1);
Adr=VGAxy((xCenter-x),(yCenter-y)); // Initial pair
fb[Adr]=color;
Adr+=x2;
fb[Adr]=color;
Adr=VGAxy((xCenter-x),(yCenter+y)); // 2nd pair
fb[Adr]=color;
Adr+=x2;
fb[Adr]=color;
Adr=VGAxy((xCenter-y),(yCenter-x)); // 3rd pair
fb[Adr]=color;
Adr+=y2;
fb[Adr]=color;
Adr=VGAxy((xCenter-y),(yCenter+x)); // 4th pair
fb[Adr]=color;
Adr+=y2;
fb[Adr]=color;
/*
I'm looking to calculate the center point address
(AdrBase = VGAxy(xCenter,yCenter)) and the (x*640)
and(y*640) and then add/subtract them along with
x/y to the base address as needed.
*/
}
Hope this works out for you.
Regards,
PJE
--- In "Eduardo Mendiola" <>
wrote:
>
> Do you know where I can get a copy of the circle drawing program?
>
> Thanks, Eduardo
>
Yahoo! Groups Links
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|