clear
clc
%clf
global phi

figure('Color',[1 1 1]);

% Define starting points:
P1 = [0; 0.5];
P2 = [0.5; 0];
P3 = [1; 0.5];

% %Change fractal level, angle constant:
% for i=1:12
%     clf
%   level = i;
%   phi = 45*pi/180;

% Change angle, level constant:
level = 12;
f=1;
for i = 1:222
    clf
    ii = i;
    if (i>111)
       ii = 223-i;
    end
    phi = (4.5+(.5*ii))*pi/180;

    % Call dragoncurve function:
    dragoncurve(level, P1, P2, P3);

    % Plot and save:
    hold off
    title(['Dragon Curve level ',num2str(level),' Phi = ', sprintf('%3.1f',phi*180/pi),' degrees'],'fontsize',20)
    axis([-0.20 +1.20 -0.35 +0.95])
    axis('equal','off');
    %saveas(gcf, ['images3/dragoncurvelevel', sprintf('%03d',level), '.png'])
    saveas(gcf, ['dcangle', sprintf('%03d',f), '.png']);
    f=f+1;
end