www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/31/07:49:26

From: David Jenkins <me AT jenkinsdavid DOT demon DOT co DOT uk>
Newsgroups: rec.games.programmer,comp.os.msdos.djgpp
Subject: Re: bresenham's circle
Date: Thu, 31 Jul 1997 03:20:15 +0100
Organization: None
Distribution: world
Message-ID: <kn5WwGAfZ$3zEwbB@jenkinsdavid.demon.co.uk>
References: <33DF4527 DOT 671 AT mindspring DOT com>
NNTP-Posting-Host: jenkinsdavid.demon.co.uk
MIME-Version: 1.0
Lines: 69
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

In article <33DF4527 DOT 671 AT mindspring DOT com>, Derek Greene
<topcoder AT mindspring DOT com> writes
>i have used bresenham's circle routines experimentally, it has GREAT
>speed (more so then lookup tables I think :) buuut, it leaves gaps,
>right gaps, in the circle, has anyone else noticed this?  can anyone
>tell me what's wrong, is there ANY way to fix this?


Is this Bresenhams circle routine??
Or is it the one where you calculate an eigth of a circle and draw the
full circle from these calcs, never seen that one in action though.

/* Quick circles.
*/

#include <stdio.h>
#include <allegro.h>
#include <time.h>


int             main()
{
    BITMAP         *buffer;
    PALLETE         pal;
    int d,x,y,r;
    double x2,y2;

        pal[0].r = 0;
        pal[0].g = 0;
        pal[0].b = 0;
        pal[1].r = 63;
        pal[1].g = 63;
        pal[1].b = 63;

    allegro_init();
    install_keyboard();
    set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0);

    set_pallete(pal);
    buffer = create_bitmap(SCREEN_W, SCREEN_H);
    x=160;
    y=100;
        while(!keypressed()){

         for (r=1 ; r<180 ; r++){
        x2=0;
        y2=r/2.0;
        for (d=1 ; d< r*7 ; d++){

            x2 =x2+y2/r;
            y2 =y2-x2/r;

           _putpixel(buffer,x+x2, y+y2, 1);

}

        vsync();
        blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
        clear(buffer);
}
}

return 0;
}

-- 
http://www.jenkinsdavid.demon.co.uk for C programmers.
David Jenkins

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019