function parallelogrammesv11(A,u,v,x,n,varargin)
% exemples:
%  parallelogrammesv11([-1;2],[-1;3],[1;3],0.1,25)
%  parallelogrammesv11([-1;2],[-1;3],[1;3],0.1,25, 'color1','b','color2','r','linewidth',2,'linestyle',':')
  ip = inputParser;
  ip.KeepUnmatched=true;
  ip.PartialMatching=false;
  checkcolor=@(x)   ( ischar(x) && ismember(x,{'k','r','g','b','y','m','c'} ) ...
                 || ( isnumeric(x) && all(size(x)==[1,3])) );
  ip.addParameter('color1','k',checkcolor);
  ip.addParameter('color2','b',checkcolor);
  ip.parse(varargin{:});
  if ~exist('namedargs2cell'), %  Matlab < R2019b, Octave < 6.1.0
    namedargs2cell = ...
    @(s) reshape ([fieldnames(s), struct2cell(s)].', 1, []);
  end
  opts=namedargs2cell(ip.Unmatched);
  clf;hold on; axis equal
  plot_para(A,u,v,'color',ip.Results.color1,opts{:})
  for i=1:n
    [A,u,v]=calcul(A,u,v,x);
    plot_para(A,u,v,'color',ip.Results.color2,opts{:})
  end
end

function plot_para(A,u,v,varargin)
  X=[A,A+u,A+u+v,A+v,A];
  plot(X(1,:),X(2,:),varargin{:})
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
