hi,all...
here are my codes on how to a draw a circle using curses,but I found
it's not a good way and there are some bugs.
#include<vector>
#include<curses.h>
using std::vector;
struct Point
{
        Point(int i_,int j_)
        {
                i = i_;
                j = j_;
        }
        int i;
        int j;

};

vector<Point>  draw_circle(const Point& center,int radius)
{
        vector<Point> vp;
        for(int i = 0; i<LINES;i++)
                for(int j = 0;j<COLS;j++)
                {
                        if((i - center.i)*(i - center.i) + (j -
center.j)*(j - center.j) ==
radius*radius )
                        {
                                vp.push_back(Point(i,j));
                                move(i,j);
                                addstr("a");
                                refresh();
                                usleep(100000);
                        }
                }
        return vp;

}

int main()
{
        Point center (22,22);
        int radius = 2;  //int radius = 1,.....take care of here..@@
        initscr();
        clear();
        draw_circle(center,radius);
        sleep(33);
        endwin();
        return 0;

}

Q1:
at main() function,
I found it is so strange that if I declare int radius = 2,or int radius
= 1,or some
others ,the picture I draw is only have four point,but if the radius is
bigger,there may be more,but the quantity is not respected.

Q2:are there a better way to draw a circle??
Thanks in advance.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---

Reply via email to