Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 422503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:05:16+00:00 2026-05-12T19:05:16+00:00

I have this code to draw an ellipse in the screen but I don’t

  • 0

I have this code to draw an ellipse in the screen but I don’t understand what does it means the long define statement, and I only want to know how to write the same code without all that confuse define statement.

#define incx() x++, dxt += d2xt, t += dxt 
#define incy() y--, dyt += d2yt, t += dyt

void ellipse(int xc, int yc, int rx, int ry, int color)
{
    int x = 0, y = ry;
    long rx2 = (long)rx*rx, ry2 = (long)ry*ry;
    long crit1 = -(rx2/4 + rx%2 + ry2);
    long crit2 = -(ry2/4 + ry%2 + rx2);
    long crit3 = -(ry2/4 + ry%2);
    long t = -rx2*y; // e(x+1/2,y-1/2) - (a^2+b^2)/4
    long dxt = 2*ry2*x, dyt = -2*rx2*y;
    long d2xt = 2*ry2, d2yt = 2*rx2;

    while (y>=0 && x<=rx)
    {
        pixel(xc+x, yc+y, color);
        if (x!=0 || y!=0)
            pixel(xc-x, yc-y, color);
        if (x!=0 && y!=0)
        {
            pixel(xc+x, yc-y, color);
            pixel(xc-x, yc+y, color);
        }
        if (t + ry2*x <= crit1 ||   //e(x+1,y-1/2) <= 0
            t + rx2*y <= crit3)     //e(x+1/2,y) <= 0
            incx();
        else if (t - rx2*y > crit2) //e(x+1/2,y-1) > 0
            incy();
        else
        {
            incx();
            incy();
        }
    }
}

I have tried to remove the define piece by piece and it doesn’t work, any suggestion?

  • 1 1 Answer
  • 3 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T19:05:16+00:00Added an answer on May 12, 2026 at 7:05 pm

    If you just want to remove it, run the code through cpp:

     cpp cpp.c > cppout.c
    

    gives me

    # 1 "cpp.c"
    # 1 "<built-in>"
    # 1 "<command-line>"
    # 1 "cpp.c"
    
    
    
    void ellipse(int xc, int yc, int rx, int ry, int color)
    {
        int x = 0, y = ry;
        long rx2 = (long)rx*rx, ry2 = (long)ry*ry;
        long crit1 = -(rx2/4 + rx%2 + ry2);
        long crit2 = -(ry2/4 + ry%2 + rx2);
        long crit3 = -(ry2/4 + ry%2);
        long t = -rx2*y;
        long dxt = 2*ry2*x, dyt = -2*rx2*y;
        long d2xt = 2*ry2, d2yt = 2*rx2;
    
        while (y>=0 && x<=rx)
        {
            pixel(xc+x, yc+y, color);
            if (x!=0 || y!=0)
                pixel(xc-x, yc-y, color);
            if (x!=0 && y!=0)
            {
                pixel(xc+x, yc-y, color);
                pixel(xc-x, yc+y, color);
            }
            if (t + ry2*x <= crit1 ||
                t + rx2*y <= crit3)
                x++, dxt += d2xt, t += dxt;
            else if (t - rx2*y > crit2)
                y--, dyt += d2yt, t += dyt;
            else
            {
                x++, dxt += d2xt, t += dxt;
                y--, dyt += d2yt, t += dyt;
            }
        }
    }
    

    The problem you may have had is the use of the comma operator in the macro. I recommend replacing the commas with ;, and putting the if parts inside {}, with line breaks. (Here I hand-inserted the { and }, then used M-x replace-string RET , RET ; C-Q C-J in Emacs, followed by C-M-\ to indent the region.)

        if (t + ry2*x <= crit1 ||
            t + rx2*y <= crit3) {
    
            x++;
            dxt += d2xt;
            t += dxt;
    
        } else if (t - rx2*y > crit2) {
            y--;
            dyt += d2yt;
            t += dyt;
    
        } else {
            x++;
            dxt += d2xt;
            t += dxt;
    
            y--;
            dyt += d2yt;
            t += dyt;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have used this code to draw a set of ellipses in C# but
I have this code to draw a triangular canvas. But I can't manage to
I want to draw image in place where I click. i have this code:
I have class where I draw image. This is code: public class CanvasdrawActivity extends
I don't know if this is the correct website, but you guys have been
I have this code and in Firefox is working well, but in Chrome I'am
I have this Code for draw a diagram in a PictureBox: private void ChkLiboData_ItemCheck(object
I have this code in jQuery, that I want to reimplement with the prototype
I have this code: chars = #some list try: indx = chars.index(chars) except ValueError:
I have this code that performs an ajax call and loads the results into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.