Thread: Drawing circles

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    12

    Question Drawing circles

    I need your help because I often experience off-by one errors when using graphic functions. I would like to write a Circle function, its prototype should look like this: void Circle(HDC hdc,double x,double y,double r);. It should draw a circle by making a call to Arc function - what will the parameters of Arc look like (use parameters of Circle, of course - i.e. hdc,x,y and r)?

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Well why dont you simply use the Ellipse() func....

    You can still have your Circle func....but like this.....

    Code:
    void Circle(HDC hdc,int x, int y, int rad){
    
    	Ellipse(hdc,x,y,rad + x,rad + y);
    
    }
    Not difficult

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    12

    Exclamation

    Sorry but I guess you're wrong in some things! First, the ellipse function actually fills the inside of an ellipse with background colour. That is why I want to use Arc function. Second thing is, that calling the ellipse function with parameters you specified will NOT draw a circle with the centre at [x;y] and radius of r. Well, I DO KNOW I should call ellipse(hdc,x-rad,y-rad,x+rad,x+rad) but that IS wrong, you'll experience that nasty off-by-one error as Petzold calls it. So, my question would be: what about ellipse(hdc,x-rad,y-rad,x+rad+1,y+rad+1)? Will that work? FUNNY NOTE: What actually I did was: I wrote the core of my app as a COM DLL server in C++ and I created the user interface in VB, which HAS a circle function )))))))))))))

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    12
    what i actually did

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Slow drawing code
    By tjpanda in forum Windows Programming
    Replies: 5
    Last Post: 05-09-2008, 05:09 PM
  2. Line Drawing Algorithm
    By Axpen in forum Game Programming
    Replies: 15
    Last Post: 08-01-2005, 06:30 PM
  3. intersecting circles (trilateration)
    By X PaYnE X in forum Windows Programming
    Replies: 3
    Last Post: 02-13-2005, 10:31 AM
  4. How to do double buffing with win32 drawing?
    By Josh Kasten in forum Windows Programming
    Replies: 2
    Last Post: 03-27-2004, 12:02 AM
  5. Drawing circles in DirectX 8
    By pdstatha in forum Game Programming
    Replies: 3
    Last Post: 07-27-2002, 04:21 PM