PROCEDURE faltkarte;

VAR
	
	pageWidth:	REAL;
	pageHeight:	REAL;
	pageFoldY: REAL;
	objectX1,objectX2,objectX3,objectX4:REAL;
	objectY1,objectY2,objectY3,objectY4,objectY5,objectY6:REAL;
	width:		REAL;
	depth1:	REAL;
	depth2:	REAL;
	height:	REAL;
Radius: REAL;
nLamellen: INTEGER;
i:INTEGER;
i2:INTEGER;

BEGIN
	
	{*Variablen berechnen*}
	pageWidth:=210;
	pageHeight:=297;
	pageFoldY:= 148.5;
	
Radius:=80;
nLamellen:=30;
height:=Radius;
width:=Radius/nLamellen;

	{*Stift einstellen*}
	penPat(2);
	penFore(0,0,65535);

	{*blatt zeichnen*}
	moveto(0,0);
	lineto(pageWidth,0);
	lineto(pageWidth,pageHeight);
	lineto(0,pageHeight);
	lineto(0,0);

{*in dieser Schleife werden die Lamellen links gezeichnet*}
	FOR i:=1 TO nLamellen DO BEGIN;
	
		{*links und rechts des Volumes berechnen*}
		objectX1:=pageWidth/2-Radius+i*width;
		objectX2:=objectX1+width;

		{*Tiefe des Körpers berechnen, steigt von volume zu volume*}
		depth1:= sqrt(sqr(radius)-sqr(radius-(radius/nLamellen*i)));

	
		{*yWerte für die Linien berechnen*}
		objectY1:=pageFoldY - depth1;
		objectY3:=pageFoldY + Radius;
		objectY2:=objectY1+Radius;		

		(*	{*papier faltkanten zeichnen*}
		penFore(65535,0,0);		
		lineTo(objectX1,pageFoldY);*)

		{*schnittkanten zeichnen links*}
		penFore(0,0,65535);
		moveto(objectX1,objectY1);
		lineto(objectX1,objectY2);
		moveto(objectX2,objectY1);
		lineto(objectX2,objectY2);

		{*Faltkanten der Objects zeichnen links*}
		penFore(65535,0,0);
		moveto(objectX1,objectY1);
		lineto(objectX2,objectY1);
		moveto(objectX1,objectY2);
		lineto(objectX2,objectY2);

        	

		IF (i=1) THEN BEGIN
			penFore(0,0,65535);
			moveto(objectX1,objectY1);
			lineto(objectX1,objectY3);
			penFore(65535,0,0);
			lineto(objectX1+Radius,objectY3);
			{*Faltkanten auf linker Seite zeichnen*}
			moveto(objectX1,pageFoldY);
			Lineto(0,pageFoldY);

FOR i2:=1 TO nLamellen-1 DO BEGIN;
objectX3:=pageWidth/2+i2*width;
	objectX4:=objectX3+width;
	depth2:= -(sqrt(sqr(radius)-sqr(radius/nLamellen*i2)));
objectY4:=pageFoldY - depth2;
	objectY6:=pageFoldY;
	objectY5:=objectY4-Radius;
{*schnittkanten zeichnen rechts*}
	penFore(0,0,65535);
	moveto(objectX3,objectY4);		
	lineto(objectX3,objectY5);
	moveto(objectX4,objectY4);
	lineto(objectX4,objectY5);

	{*Faltkanten der Objects zeichnen rechts*}
	penFore(65535,0,0);
	moveto(objectX3,objectY4);
	lineto(objectX4,objectY4);
	moveto(objectX3,objectY5);
	lineto(objectX4,objectY5);

END;
IF (i2=nLamellen) THEN BEGIN
		penFore(0,0,65535);
		moveto(objectX4,ObjectY6);
		lineto(objectX4,ObjectY6-Radius);
	{*Faltkante unten rechts*}
		penFore(65535,0,0);
		lineto(objectX4-Radius,objectY6-Radius);
	{*Faltkante Seitenhalbierende rechts*}
		moveto(objectX4,pageFoldY);
		lineto(pageWidth,pageFoldY);

END;

END;
END;		
END;
RUN(faltkarte);