%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%	Drangon curve by Atsushi Nakano.
%	Uses the library 'graphic' and works
% only with LMNtal Java.
% To terminate, kill the process.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

graphic.use.
go:-{
	window.
	size(640,530).
	name("hoge").

	now(1).
	a(179,140,400,350, 7).
	
	a(AX,AY,BX,BY,N) :-
	   CX = AX+(BX-AX+AY-BY)/2,
	   CY=BY+(BX-AX+AY-BY)/2, N > 0 |
     a(AX,AY,CX,CY,N-1),a(BX,BY,CX,CY,N-1).
	
	a(AX,AY,BX,BY,N), now(NOW) :-
	   CX = AX+(BX-AX+AY-BY)/2,
	   CY=BY+(BX-AX+AY-BY)/2, N = 0,int(NOW) |
	{draw,name(NOW),getpic("line"),position(AX,AY,CX,CY)},
	{draw,name(NOW+1),getpic("line"),position(BX,BY,CX,CY)},
	now(NOW+2).
	
}.