home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / Dloads / OTHERUTI / TCPP30-3.ZIP / EXAMPLES.ZIP / FIGDEMO.CPP < prev    next >
C/C++ Source or Header  |  1992-02-18  |  2KB  |  64 lines

  1. // Borland C++ - (C) Copyright 1991 by Borland International
  2.  
  3. // FIGDEMO.CPP -- Exercise in Getting Started
  4.  
  5. // demonstrates the Figures toolbox by extending it with
  6. // a new type Arc.
  7.  
  8. // Link with FIGURES.OBJ and GRAPHICS.LIB
  9.  
  10. #include "figures.h"
  11. #include <graphics.h>
  12. #include <conio.h>
  13.  
  14. class Arc : public Circle {
  15.    int StartAngle;
  16.    int EndAngle;
  17. public:
  18. // constructor
  19.    Arc(int InitX, int InitY, int InitRadius, int InitStartAngle, int
  20.        InitEndAngle) : Circle (InitX, InitY, InitRadius) {
  21.        StartAngle = InitStartAngle; EndAngle = InitEndAngle;}
  22.    void Show();  // these functions are virtual in Point
  23.    void Hide();
  24. };
  25.  
  26. // Member functions for Arc
  27.  
  28. void Arc::Show() 
  29. {
  30.    Visible = true;
  31.    arc(X, Y, StartAngle, EndAngle, Radius);
  32. }
  33.  
  34. void Arc::Hide()
  35. {
  36.    int TempColor;
  37.    TempColor = getcolor();
  38.    setcolor (getbkcolor());
  39.    Visible = false;
  40.    // draw arc in background color to hide it
  41.    arc(X, Y, StartAngle, EndAngle, Radius);
  42.    setcolor(TempColor);
  43. }
  44.  
  45. int main()   // test the new Arc class
  46. {
  47.    int graphdriver = DETECT, graphmode;
  48.    initgraph(&graphdriver, &graphmode, "..\\bgi");
  49.    Circle ACircle(151, 82, 50);
  50.    Arc AnArc(151, 82, 25, 0, 190);
  51.  
  52.    // you first drag an arc using arrow keys (5 pixels per key)
  53.    // press Enter when tired of this!
  54.    // Now drag a circle (10 pixels per arrow key)
  55.    // Press Enter to end FIGDEMO.
  56.  
  57.    AnArc.Drag(5);   // drag increment is 5 pixels
  58.    AnArc.Hide();
  59.    ACircle.Drag(10); // now each drag is 10 pixels
  60.    closegraph();
  61.    return 0;
  62. }
  63.  
  64.