//		  ÚÄÄÄÄÄÄÄ¿
//	ÄÄÄÄÄÄÄÄÄ>³ AVNER ³
//	ÄÄÄÄÄÄÄÄÄ>³  BEN  ³ÄÄÄÄÄÄ> Software Engineering Method
//		  ÀÄÄÄÄÄÄÄÙ
//	10 Dov-Hoz st. Tel-Aviv 63416 Israel tel. 972-3-221535

// The Screen NAVigator, ver 1.20 August 1990
// Copyright (c) 1990 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.
// 13.7.90  - tested under TurboC++.

// Site history (of this copy):
// __.__.__ ____________ : __________________.

#include "/mtad/snav/snav2.hpp"
#include "demo3.hpp"

zigzag :: zigzag(int inlen, direction &indir1, direction &indir2,
 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, direction &indir, 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->len()) {
		tail.list(scr,&pt,FALSE); sk->turn();
		if (sk->len()>1)
			{ tail.list(scr,&pt,FALSE); sk->turn(); }
		sk->contract();
	}
}
