home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c100 / 1.ddi / SNAV0111.ZIP / DEMO3.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1990-04-16  |  2.6 KB  |  90 lines

  1. //          ┌───────┐
  2. //    ─────────>│ AVNER │
  3. //    ─────────>│  BEN  │──────> Software Engineering Method
  4. //          └───────┘
  5. //    10 Dov-Hoz st. Tel-Aviv 63416 Israel tel. 972-3-221535
  6.  
  7. // The Screen NAVigator, ver 1.10 April 1990
  8. // Copyright (c) 1989 by Avner Ben
  9. // Snav is not, and never was, free software.
  10. // for conditions for use refer to file "copyrigh.txt"
  11.  
  12. // The Screen Navigator is an object-oriented device-independent
  13. // character-graphics driver package, written in the C++ language,
  14. // distributed in the form of C++ source code.
  15. // For further information refer to the documentation files.
  16.  
  17. // this simple example is intended as a template to be extended and modified
  18. // by the user, provided the above title and copyright notice are unchanged
  19. // and are not ommitted.
  20.  
  21. /***************************************************************************/
  22.  
  23. // demonstration part 3 - source code.
  24. // Sample specific shapes that may be implemented by the user after
  25. // the generic shape of sanv-2.
  26.  
  27. // History:
  28. // 2.11.89 avner ben coded.
  29. /////// snav v1.1
  30. // 8.3.90  avner ben - C++ v2.0 upgrade.
  31.  
  32. // Site history (of this copy):
  33. // __.__.__ ____________ : __________________.
  34.  
  35. #include "snav2.hpp"
  36. #include "demo3.hpp"
  37.  
  38. zigzag :: zigzag(int inlen, const direction &indir1, const direction &indir2,
  39.  const weight_d &inwgt) : shape(NULL,"zigzag"), fstdir(indir1), nextdir(indir2),
  40.  wgt(inwgt)
  41. {
  42.     len=inlen;
  43.     if (axis(fstdir)==axis(nextdir)) nextdir.clockwise();
  44.     // allocate pattern element
  45.     int c1, c2;
  46.     if (hdim.directions()>=fstdir) {
  47.         c1=3; c2=2; // aspect ratio 1:2
  48.     } else {
  49.         c1=2; c2=3;
  50.     }
  51.     append_stroke(new stroke(c1,fstdir,wgt));
  52.     append_stroke(new stroke(c2,nextdir,wgt));
  53.     // the rest is for the lister...
  54. }
  55.  
  56. void zigzag :: list(panel *scr, point_pos *pt0)
  57. {
  58.     point_pos pt=*pt0;
  59.     for (int i=1; i<=len; i++)
  60.         shape::list(scr,&pt,FALSE);
  61. }
  62.  
  63. spiral :: spiral(int inlen, const direction &indir, const weight_d &inwgt)
  64.  : shape(NULL,"spiral"), dir(indir), wgt(inwgt)
  65. {
  66.     len=inlen;
  67.     // first three sides are equal
  68.     direction tdir=dir;
  69.     // first three sides are equal
  70.     for (int i=1; i<=3; i++) {
  71.         append_stroke(new stroke(len,tdir,wgt));
  72.         tdir.clockwise();
  73.     }
  74.     // the rest is for the lister...
  75. }
  76.  
  77. void spiral :: list(panel *scr, point_pos *pt0)
  78. {
  79.     point_pos pt=*pt0;
  80.     shape::list(scr,&pt,FALSE);
  81.     stroke *sk=new stroke(len-1,dir,wgt); shape tail(sk);
  82.     sk->turn(); sk->turn(); sk->turn();
  83.     while (sk->ask_len()) {
  84.         tail.list(scr,&pt,FALSE); sk->turn();
  85.         if (sk->ask_len()>1)
  86.             { tail.list(scr,&pt,FALSE); sk->turn(); }
  87.         sk->contract();
  88.     }
  89. }
  90.