/*
anime-pencere v1.0 Acilan animasyonlu pencere ornegi.
Copyright (C) 2005 Engin KUZU

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

//http://www.gnu.org/copyleft/gpl.html
//Turkce cevirisi: http://www.belgeler.org/howto/gpl_copy.html
//Web: http://www.enginkuzu.org

#include <stdio.h>
#include <conio.h>

void yaz(int x,int y,char c)
{
	gotoxy(x,y);textcolor(2);cprintf("%c",c);
}

void pencere(int a,int b,int c,int d,int e,int f)
{
	int k1,k2,k3,k4,i,j;
	char c1,c2,c3,c4,c5,c6;

	_setcursortype(_NOCURSOR);
	switch(e)
	{
		case 1:
			c1=218;c2=191;c3=192;c4=217;c5=196;c6=179;
			break;
		case 2:
			c1=201;c2=187;c3=200;c4=188;c5=205;c6=186;
			break;
		case 3:
			c1=219;c2=219;c3=219;c4=219;c5=219;c6=219;
			break;
	}

	if( (b-a)%2 == 1)
	{
		k1=(b-a)/2+a;
		k2=k1+1;
	}
	else
	{
		k1=(b-a)/2+a-1;
		k2=k1+2;
	}
	if( (d-c)%2 == 1)
	{
		k3=(d-c)/2+c;
		k4=k3+1;
	}
	else
	{
		k3=(d-c)/2+c-1;
		k4=k3+2;
	}

	while( a!=k1 || c!=k3 )
	{

		if( a==k1 && c==k3 )
			break;
		if( a==k1 )
		{
			k3--;k4++;
		}
		else if(c==k3)
		{
			k1--;k2++;
		}
		else
		{
			k1--;k3--;k2++;k4++;
		}
		yaz(k1,k3,c1);
		for(i=k1+1;i<k2;i++)
			yaz(i,k3,c5);
		yaz(k2,k3,c2);
		for(j=k3+1;j<k4;j++)
		{
			yaz(k1,j,c6);
			for(i=k1+1;i<k2;i++)
				yaz(i,j,0);
			yaz(k2,j,c6);

			if(f==1){
				gotoxy(k2+1,j);textbackground(1);
				cprintf("%c",0);textbackground(0);}
		}
		if(f==1){
			gotoxy(k2+1,j);textbackground(1);
			cprintf("%c",0);textbackground(0);}

		yaz(k1,k4,c3);
		for(i=k1+1;i<k2;i++)
		{
			yaz(i,k4,c5);
			if(f==1){
				gotoxy(i,k4+1);textbackground(1);
				cprintf("%c",0);textbackground(0);}
		}
		yaz(k2,k4,c4);
		if(f==1){
			gotoxy(k2,k4+1);textbackground(1);
			cprintf("%c%c",0,0);textbackground(0);}

		delay(20);
	}
}
void main()
{
	clrscr();

	pencere(10,60,2,8,1,1);
	pencere(10,50,11,17,2,1);
	pencere(13,50,20,35,3,1);

	getch();
}
