function parallelogrammesv4(A,u,v,x,n,color1,color2)
% Version arguments optionnels et utilisant la fonction nargin
% Exemples:
%  parallelogrammesv4([-1,2],[-2,3],[1,3],0.1,25)
%  parallelogrammesv4([-1,2],[-2,3],[1,3],0.1,25,'m')
%  parallelogrammesv4([-1,2],[-2,3],[1,3],0.1,25,'m','g')
%  parallelogrammesv4([-1,2],[-2,3],[1,3],0.1,25,[],'g')
  assert(ismember(nargin,5+[0:2]),sprintf('Number of input parameters: 5 to 7, given %d',nargin))
  if nargin<6 || isempty(color1), color1='k';end
  if nargin<7 || isempty(color2), color2='b';end
  clf;hold on;axis equal
  plot_para(A,u,v,color1)
  for i=1:n
    [A,u,v]=calcul(A,u,v,x);
    plot_para(A,u,v,color2)
  end
end

function plot_para(A,u,v,color)
  X=[A,A+u,A+u+v,A+v,A];
  plot(X(1,:),X(2,:),color)
end

function [Ap,up,vp]=calcul(A,u,v,x)
  Ap=A+x*u;
  up=u+x*(v-u);
  vp=v-x*(u+v);
end
