PROCEDURE skyline;
CONST 
	pageWidth=210;
	pageHeight=297;
	pageFoldY=118.5;
VAR
	d1X,d2x,d3x,d1y,d2y,d3y:REAL;
	p1x,p1y,p2x,p2y,p3x,p3y:REAL;
	ox1,oy1,oy2,oy3,oy4:REAL;
	depth,height,zufall,width:	REAL;
	i:INTEGER;
	makeRandomHeight:BOOLEAN;
	nVolumes:REAL;

BEGIN

	
				{*dina a4 blatt zeichnen*}

	penFore(0,0,65535);
	moveto(0,0);
	lineto(pageWidth,0);
	lineto(pageWidth,pageHeight);
	lineto(0,pageHeight);
	lineto(0,0);
	moveto(40,pageFoldY);

				{*Skyline}

	depth:=30;
	p1x:=35;
	p1y:=150;
	moveTo(p1x,p1y);

	FOR i:=1 TO 28 DO BEGIN
		zufall:=random;
		p2x:=p1x+(random*10);
		p2Y:=p1y;
			
					{*Volumen schräg}

		IF zufall>0.75 THEN BEGIN
		IF zufall<0.8  THEN BEGIN
			lineTo(p1x,p1y);
			penFore(65535,0,0);
			p2y:=p1y+random*20-10;
			lineto(p2x,p2y);	

			penFore(65535,0,0);
			moveTo(p2x,p2y);
			lineTo(p1x,p1y);
	
		END;
		END;

					{*Volumen doppelt gefaltet}

		IF zufall>0.8 THEN BEGIN
		IF p2x>(p1x+5) THEN BEGIN
			moveTo(p1x,p1y);
			penFore(65535,0,0);
			p3y:=p1y+5+random*7;
			lineto(p1x+2,p1y);
			penFore(0,0,65535);
			lineto(p1x+2,p3y);
			lineto(p2x-2,p3y);
			lineto(p2x-2,p1y);
			penFore(65535,0,0);
			lineTo(p2x,p2y);
			
			penFore(0,0,65535);
			lineTo(p2x,p2y+depth);		

			penFore(65535,0,0);
			lineTo(p1x,p2y+depth);

			penFore(0,0,65535);
			lineTo(p1x,p1y);

		END;
		END;
		
				{*Volumen normal 1}
		
		IF zufall>0.8 THEN BEGIN
		IF p2x<(p1x+5) THEN BEGIN
			moveTo(p1x,p1y);
			penFore(65535,0,0);
			lineTo(p2x,p2y);
			
			penFore(0,0,65535);
			lineTo(p2x,p2y+depth);		

			penFore(65535,0,0);
			lineTo(p1x,p2y+depth);

			penFore(0,0,65535);
			lineTo(p1x,p1y);
		
			penFore(65535,0,0);
			moveTo(p2x,p2y);
			lineTo(p1x,p1y);
			
		END;
		END;

				{*Volumen normal}

		IF zufall<0.75 THEN BEGIN
			moveTo(p1x,p1y);
			penFore(65535,0,0);
			lineTo(p2x,p2y);
		
			penFore(0,0,65535);
			lineTo(p2x,p2y+depth);		

			penFore(65535,0,0);
			lineTo(p1x,p2y+depth);

			penFore(0,0,65535);
			lineTo(p1x,p1y);
		
			penFore(65535,0,0);
			moveTo(p2x,p2y);
			lineTo(p1x,p1y);
			
		END;

		moveto(p2x,p2y);
		penFore(0,0,65535);
		p1x:=p2X;
		p1Y:=p2Y+random*16-8;
		lineTo(p2x,p1y);

	END;

	
				{*Kirche im Dorf*}
	
	penFore(0,0,65535);
	moveTo(60,(pageFoldY - depth-10));
	lineTo(60,(pageFoldY - depth));
	lineTo(63,(pageFoldY - depth+15));
	lineTo(66,(pageFoldY - depth));

				{*Dorf*}
	depth:=10;
	d1x:=66;
	d1y:=pageFoldY - 30;
	moveTo(d1x,d1y);

	FOR i:=1 TO 6 DO BEGIN

		zufall:=random;
		d2x:=d1x+i*10;
		d3x:=d2x+10;
		d2Y:=d1y+depth;
		d3y:=d1y+random*4-2;

	IF zufall>0.75 THEN BEGIN
		
		lineto(d3x-5,d1y+random*5);
		lineto(d3x,d1y);
		lineto(d3x,d1y);
	
		END;

	IF zufall<0.75 THEN BEGIN

		penFore(65535,0,0);
		lineto(d3x,d1y);
		penFore(0,0,65535);
		lineto(d3x,d2y);
		penFore(65535,0,0);
		lineto(d2x,d2y);
		penFore(0,0,65535);
		lineto(d2x,d1y);
		moveto(d3x,d1y);

	

		END;

	END;

		{*Faltkanten Dorf}

	moveTo(d3x,d3y);
	lineTo(d3x,(pageFoldY - 40));
	penFore(65535,0,0);
	lineto(60,(pageFoldY - 40));

		{*Faltkanten Skyline}

	moveto(p2x,p1y);
	penFore(0,0,65535);
	lineto(P2x,pageFoldY - 30);
	penFore(65535,0,0);
	lineto(d3x,pageFoldY - 30);

		{*Anfangsgebäudegebäude}

	penFore(65535,0,0);
	moveto(30,pagefoldy+20);
	lineto(35,pageFoldY +20);
	penFore(0,0,65535);
	lineto(35,pageFoldY +50);
	penFore(65535,0,0);
	lineto(30,pageFoldY +50);
	penFore(0,0,65535);
	lineto(30,pageFoldY +50);
	penFore(0,0,65535);
	lineto(30,pageFoldY -30);
	penFore(65535,0,0);
	lineto(60,pageFoldY -30);

	nVolumes:=pAnzahlSterne;
	width:= ((pageWidth-80)-(nVolumes+1))/(nVolumes);

			{*Sterne*}

	FOR i:=0 TO nVolumes-1 DO BEGIN

		oX1:=20+Random*pageWidth-20;

		IF (pmakerandomheight=true) THEN BEGIN
			height:=10+Random*25;
		END
		ELSE BEGIN
			height:=pHöhe;
		END;

		oY1:=(pageFoldY - depth)-10;
		oY3:=(pageFoldY-depth) + height;
		oY2:=oY3-10;
		oY4:=pageHeight-70+Random*40;

		penFore(0,0,65535);
		moveto(ox1,oY4);
		lineto(ox1+1.5,oY4-1);
		lineto(ox1,oY4-3);
		lineto(ox1+2.5,oY4-1.5);
		lineto(ox1+5,oY4-3);
		lineto(ox1+3.3,oY4-1);
		lineto(ox1+5,oY4);
		lineto(ox1+3,oY4);
		lineto(ox1+2.5,oY4+2.5);
		lineto(ox1+2,oY4);
		lineto(ox1,oY4);
		moveto(ox1+10+random*90,oY4+height);
	END;

		{*faltlinie Blatt*}
	
	penFore(65535,0,0);
	moveto(p2x,pagefoldy);
	lineto(pagewidth,pagefoldy);
	moveto(0,pagefoldy);
	lineto(30,pagefoldy);

END;
RUN(skyline);