function parallelogrammesv5(A,u,v,x,n,varargin)
% Version avec arguments optionnels utilisant varargin et nargin
% Exemples:
%  parallelogrammesv5([-1,2],[-2,3],[1,3],0.1,25)
%  parallelogrammesv5([-1,2],[-2,3],[1,3],0.1,25,'m')
%  parallelogrammesv5([-1,2],[-2,3],[1,3],0.1,25,'m','g')
%  parallelogrammesv5([-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))
  color1='k';color2='b';
  if nargin>=6 && ~isempty(varargin{1}),color1=varargin{1};end
  if nargin==7 && ~isempty(varargin{2}),color2=varargin{2};end
  clf;hold on;axis equal
  plot_para(A,u,v,'k')
  for i=1:n
    [A,u,v]=calcul(A,u,v,x);
    plot_para(A,u,v,'b')
  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
