function maple
% maple Fraktalas, pagal M.F. Barnsley, L.P. Hurd,
% fractal Image Compression, A.K. Peters Ltd., 1993
% Drakonas apibreziamas 24-iais skaiciais:
%49 1 25 0 62 -2; 27 52 0 -40 36 56;
%18 -73 88 50 26 8; 4 -1 52 50 0 32;

n=128;
N=n*2^6;
ll=[n*2^0 n*2^1 n*2^2 n*2^3 n*2^4 n*2^5 n*2^6];
x=zeros(2,N); ii=randperm(N);
b=[0 1]; 
w{1}=[49 1 25 0 62 -2]/100; 
w{2}=[27 52 0 -40 36 56]/100; 
w{3}=[18 -73 88 50 26 8]/100; 
w{4}=[4 -1 52 50 0 32]/100; 
x(:,1)=-inv([w{1}(1)-1 w{1}(2); w{1}(4)-1 w{1}(5)])*[w{1}(3);w{1}(6)];

c='gbry';

l=1;
for k=2:N,
 i=mod(ii(k),4)+1;
 x(:,k)=[w{i}(1:2); w{i}(4:5)]*x(:,k-1)+[w{i}(3); w{i}(6)];
if k==ll(l),
  figure(l); clf; plot(x(1,:),-x(2,:),'k.','markersize',3); 
  title(['Klevo lapas, iteracija=' num2str(k)]); l=l+1;
end;
end;
