home *** CD-ROM | disk | FTP | other *** search
- // ┌───────┐
- // ─────────>│ AVNER │
- // ─────────>│ BEN │──────> Software Engineering Method
- // └───────┘
- // 10 Dov-Hoz st. Tel-Aviv 63416 Israel tel. 972-3-221535
-
- // The Screen NAVigator, ver 1.10 April 1990
- // Copyright (c) 1989 by Avner Ben
- // Snav is not, and never was, free software.
- // for conditions for use refer to file "copyrigh.txt"
-
- // The Screen Navigator is an object-oriented device-independent
- // character-graphics driver package, written in the C++ language,
- // distributed in the form of C++ source code.
- // For further information refer to the documentation files.
-
- // this simple example is intended as a template to be extended and modified
- // by the user, provided the above title and copyright notice are unchanged
- // and are not ommitted.
-
- /***************************************************************************/
-
- // demonstration part 3 - source code.
- // Sample specific shapes that may be implemented by the user after
- // the generic shape of sanv-2.
-
- // History:
- // 2.11.89 avner ben coded.
- /////// snav v1.1
- // 8.3.90 avner ben - C++ v2.0 upgrade.
-
- // Site history (of this copy):
- // __.__.__ ____________ : __________________.
-
- #include "snav2.hpp"
- #include "demo3.hpp"
-
- zigzag :: zigzag(int inlen, const direction &indir1, const direction &indir2,
- const weight_d &inwgt) : shape(NULL,"zigzag"), fstdir(indir1), nextdir(indir2),
- wgt(inwgt)
- {
- len=inlen;
- if (axis(fstdir)==axis(nextdir)) nextdir.clockwise();
- // allocate pattern element
- int c1, c2;
- if (hdim.directions()>=fstdir) {
- c1=3; c2=2; // aspect ratio 1:2
- } else {
- c1=2; c2=3;
- }
- append_stroke(new stroke(c1,fstdir,wgt));
- append_stroke(new stroke(c2,nextdir,wgt));
- // the rest is for the lister...
- }
-
- void zigzag :: list(panel *scr, point_pos *pt0)
- {
- point_pos pt=*pt0;
- for (int i=1; i<=len; i++)
- shape::list(scr,&pt,FALSE);
- }
-
- spiral :: spiral(int inlen, const direction &indir, const weight_d &inwgt)
- : shape(NULL,"spiral"), dir(indir), wgt(inwgt)
- {
- len=inlen;
- // first three sides are equal
- direction tdir=dir;
- // first three sides are equal
- for (int i=1; i<=3; i++) {
- append_stroke(new stroke(len,tdir,wgt));
- tdir.clockwise();
- }
- // the rest is for the lister...
- }
-
- void spiral :: list(panel *scr, point_pos *pt0)
- {
- point_pos pt=*pt0;
- shape::list(scr,&pt,FALSE);
- stroke *sk=new stroke(len-1,dir,wgt); shape tail(sk);
- sk->turn(); sk->turn(); sk->turn();
- while (sk->ask_len()) {
- tail.list(scr,&pt,FALSE); sk->turn();
- if (sk->ask_len()>1)
- { tail.list(scr,&pt,FALSE); sk->turn(); }
- sk->contract();
- }
- }
-