ts-7000
[Top] [All Lists]

[ts-7000] Re: Frame Buffer Programming ? Solved - example circle drawing

To:
Subject: [ts-7000] Re: Frame Buffer Programming ? Solved - example circle drawing program
From: "PeterElliot" <>
Date: Tue, 22 Aug 2006 23:36:30 -0000
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

<*> 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/
 


<Prev in Thread] Current Thread [Next in Thread>
Admin

Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU