GDI - Issue while drawing Arc

This is a discussion on GDI - Issue while drawing Arc within the Game Programming forums, part of the General Programming Boards category; Hello, I am trying to make, Arc, Using GDI. There is a problem that I am facing while rendering Arc ...

  1. #1
    Registered User
    Join Date
    Dec 2011
    Posts
    12

    Unhappy GDI - Issue while drawing Arc

    Hello,
    I am trying to make, Arc, Using GDI. There is a problem that I am facing while rendering Arc for the angles life, 90 to 91, 180 to 181, 270 to 271. Following is the code and output snapshot.

    //CODE SEGMENT

    ...

    // Create a geometric pen.

    LOGBRUSH logBrush;
    logBrush.lbStyle = BS_SOLID;
    logBrush.lbColor = RGB(0,0,0);
    CPen myPen2(PS_SOLID|PS_GEOMETRIC|PS_ENDCAP_SQUARE |PS_JOIN_MITER, 50, &logBrush);
    pDC->SelectObject(&myPen2);

    // First arc of 270 degree
    pDC->Arc(100,100,300,300,200,100,100,200);//at angle 270

    // second arc of 90 degree
    pDC->MoveTo(450,400);
    pDC->AngleArc(450, 400, 150, 0.0f, 90.0f);

    ...


    Here is the output :

    Name:  correct_Arcs.JPG
Views: 188
Size:  11.8 KB



    THIS OUTPUT IS CORRECT ... Follow the below small step to get the unexpected behaviour.

    and when I change the angle the output is wiered. Check by changing the last parameter of first arc to 202 instead of 200. And change the angle, of second arc to 91.0f, to see the problem.
    this is only happening for angles like, 91, 181, 271. I am not sure how this is happening, may be some quadrant related calculations are causing this. :S
    Can anybody tell me how I can fix this issue ? Is this related to joints ? can you guide me what exactly is SetMiterLimit(...) does ?
    Is this is API issue ?
    Thanks in advance.
    NJ

  2. #2
    Registered User
    Join Date
    Dec 2011
    Posts
    12
    here is the output after making the change to the angle as 91.0f degree.
    Name:  incorrect_output.JPG
Views: 166
Size:  6.2 KB

  3. #3
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    I assume you're talking about the little crack that appears? It does seem to be an API issue, although I don't feel like coding something up to test it myself. Try using different params (ENDCAP, JOIN, etc) for your pen.
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

  4. #4
    Registered User
    Join Date
    Dec 2011
    Posts
    12
    I have used the pen as PS_ENDCAP_SQUARE and joint as PS_JOIN_MITER. Yes I am taking about the crack that appears, also the circular/rounded end, which should not come as my end cap I am setting to Square. Also, I noticed that, even if I code the angle as 91. the expected drawing should go beyond 90 degres, which in my case will be a little more towards, left hand side. but that does not happen.

  5. #5
    Registered User
    Join Date
    Dec 2011
    Posts
    12
    thanks for the response. I don't want you to code it so gave both the pics. before and after the modifications

    Again, thanks for the reply, looking forward to solve this ASAP. Will try and update
    Happy coding.

    Thanks,
    NJ

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. GDI - Issue while drawing Arc
    By N Jagdish in forum C++ Programming
    Replies: 1
    Last Post: 02-07-2012, 03:58 AM
  2. bandwidth issue / network issue with wireless device communication
    By vlrk in forum Networking/Device Communication
    Replies: 0
    Last Post: 07-05-2010, 11:52 PM
  3. Drawing a map.
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 04-18-2002, 12:52 PM
  4. Drawing
    By SushiFugu in forum Windows Programming
    Replies: 1
    Last Post: 02-15-2002, 05:13 PM
  5. Drawing
    By bluehead in forum C++ Programming
    Replies: 3
    Last Post: 01-21-2002, 03:18 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21