circles.cpp
Upload User: sxdsqi
Upload Date: 2007-06-24
Package Size: 192k
Code Size: 2k
Development Platform:

Visual C++

  1.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 // circles.cpp
  2. // circles as graphics objects
  3. #include "msoftcon.h"         // for graphics functions
  4. ////////////////////////////////////////////////////////////////
  5. class circle                  //graphics circle
  6.    {
  7.    protected:
  8.       int xCo, yCo;           //coordinates of center
  9.       int radius;             
  10.       color fillcolor;        //color
  11.       fstyle fillstyle;       //fill pattern
  12.    public:                    //sets circle attributes
  13.       void set(int x, int y, int r, color fc, fstyle fs)
  14.          {
  15.          xCo = x;
  16.          yCo = y;
  17.          radius = r;
  18.          fillcolor = fc;
  19.          fillstyle = fs;
  20.          }
  21.       void draw()             //draws the circle                          
  22.          {
  23.          set_color(fillcolor);              //set color
  24.          set_fill_style(fillstyle);         //set fill
  25.          draw_circle(xCo, yCo, radius);     //draw solid circle            
  26.          }
  27.    };
  28. ////////////////////////////////////////////////////////////////
  29. int main()
  30.    {
  31.    init_graphics();           //initialize graphics system
  32.    circle c1;                 //create circles
  33.    circle c2; 
  34.    circle c3;
  35.                               //set circle attributes
  36.    c1.set(15, 7, 5, cBLUE, X_FILL);
  37.    c2.set(41, 12, 7, cRED, O_FILL);
  38.    c3.set(65, 18, 4, cGREEN, MEDIUM_FILL);
  39.    c1.draw();                 //draw circles
  40.    c2.draw();
  41.    c3.draw();
  42.    set_cursor_pos(1, 25);     //lower left corner
  43.    return 0;
  44.    }