Source code used to draw 5 special-case shapes for "rectangle" documentation

% Draw special cases of a "rectangle with rounded or slanted corners."

% Case "A".
% Make the rectangle "all round" at two ends (left and right).
%    -- Since NPointsInCurve == 30 (the default), the patch
%       object is drawn with 4*30+2+4=126 vertices.
h = 2;
davinci( 'rectangle', 'Position',     [0 0], ...
                      'Width',        4, ...
                      'Height',       h, ...
                      'DrawMethod',   'patch', ...
                      'CornerRadius', h/2, ...
                      'EdgeColor',    'k' );
hold on

% Case "B".
% Same thing, but up/down.
w = 2;
davinci( 'rectangle', 'Position',     [5 0], ...
                      'Width',        w, ...
                      'Height',       4, ...
                      'DrawMethod',   'patch', ...
                      'CornerRadius', w/2, ...
                      'EdgeColor',    'k' );

% Case "C".
% Draw a circle.
%    -- Set Width and Height equal to each other, and
%       CornerRadius equal to half the Width.
%    -- Since NPointsInCurve == 30 (the default), the patch
%       object is drawn with 4*30+4 = 124 vertices.
w = 3;
davinci( 'rectangle', 'Position',     [10 0], ...
                      'Width',        w, ...
                      'Height',       w, ...
                      'DrawMethod',   'patch', ...
                      'CornerRadius', w/2, ...
                      'EdgeColor',    'k' );

% Case "D".
% Draw a regular octogon.
%    -- Set NPointsInCurve = 0 to make the four corners
%       of the "rectangle" be slanted.
%    -- Set Width = Height.
%    -- Set appropriate relationship between CornerRadius
%       and Width to make the octogon regular.
cr = 1;
davinci( 'rectangle', 'Position',       [15 0], ...
                      'Width',          2*cr+sqrt(2)*cr, ...
                      'Height',         2*cr+sqrt(2)*cr, ...
                      'DrawMethod',     'patch', ...
                      'CornerRadius',   cr, ...
                      'NPointsInCurve', 0, ...
                      'Color',          'r' );

% Case "E".
% Draw a diamond without using rotation.
%    -- Set NPointsInCurve = 0 to make the four corners
%       of the "rectangle" be slanted.
%    -- Set Width = Height.
%    -- Set CornerRadius = Width/2.
w = 3;
davinci( 'rectangle', 'Position',       [20 0], ...
                      'Width',          w, ...
                      'Height',         w, ...
                      'DrawMethod',     'patch', ...
                      'CornerRadius',   w/2, ...
                      'NPointsInCurve', 0 );

daspect( [1 1 1] )
hold off