# Source code used to draw miscellaneous examples for "curly_bracket" documentation

```% Draw miscellaneous examples of "curly_bracket"s.

% Bracket "A".
%   -- Include a color gradient across the bracket.  Make the color
%      be a function of distance from the "Position" point on the
%      bracket.
%        -- Our approach is to draw the bracket, save the graphics
%           handles returned by davinci(), then use the graphics
%           handles to modify the two patch objects that make up
%           the bracket.
px = 0;      % Position x-coordinate.
py = -0.5;   % Position y-coordinate.
h = davinci( 'curly_bracket', 'Position', [px py], 'Height',     3, ...
'Width',     10, ...
'Rotation', -90 );
% Loop over the two half-brackets.
name = { 'half_bracket_1' 'half_bracket_2' };
for i = 1: 2
% Extract the vertex coordinates.
vc = h.(name{i}).Vertices;
% Determine the # of vertices.
sz = size( vc );
N = sz(1);   % N = # of vertices on this half-bracket's patch object.
% Compute the distance of each vertex from the bracket's "Position" point.
dist = sqrt( (vc(:,1)-px).^2 + (vc(:,2)-py).^2 );
% Normalize this distance, so the distances are all in the range 0 to 1.
dist = dist ./ max(dist(:));
% Replicate "dist" three times so it is N x 3.
dist = repmat( dist, 1, 3 );
% Set the color of all N vertices to a slightly darkened red ([.85 0 0]).
color = repmat( [.85 0 0], N, 1 );
% Multiply the normalized distance by the color [.85 0 0].
color = color .* dist;
h.(name{i}).set( 'FaceVertexCData', color, 'FaceColor', 'interp', 'EdgeColor', 'k' )
end
hold on

% Brackets "B" thru "F" illustrate different ratios of Height/Width.

% Bracket "B".
davinci( 'curly_bracket', 'Position', [5  3], 'Height', 0.5, ...
'Width',  5 );

% Bracket "C".
davinci( 'curly_bracket', 'Position', [5  1], 'Height', 1, ...
'Width',  5 );

% Bracket "D".
davinci( 'curly_bracket', 'Position', [5 -1], 'Height', 2, ...
'Width',  5 );

% Bracket "E".
davinci( 'curly_bracket', 'Position', [5 -3], 'Height', 2, ...
'Width',  3 );

% Bracket "F".
davinci( 'curly_bracket', 'Position', [5 -5], 'Height', 2, ...
'Width',  2 );

% Bracket "G".
%   -- Set "FaceColor" to yellow and include a rim around the bracket.
davinci( 'curly_bracket', 'Position', [9  2], 'Height',      1, ...
'Width',       5, ...
'Rotation',  -90, ...
'FaceColor', 'y', ...
'EdgeColor', 'k' );

% Bracket "H".
%   -- Set "FaceColor" to orange and include a rim around the bracket.
davinci( 'curly_bracket', 'Position', [12  2], 'Height',           1, ...
'Width',            5, ...
'Rotation',        90, ...
'FaceColor', [1 .5 0], ...  % Orange.
'EdgeColor',      'k' );

% Bracket "I".
%   -- Set the "FaceColor" to white and include a rim around the bracket.
davinci( 'curly_bracket', 'Position', [9 -3.2], 'Height',     2, ...
'Width',      4.5, ...
'Rotation', -90, ...
'FaceColor', 'w', ...
'EdgeColor', 'k' );

% Bracket "J".
%   -- Include a transparency gradient across the bracket.  Make the
%      transparency ("alpha") be a function of distance from the
%      "Position" point on the bracket.
%        -- Our approach is to draw the bracket, save the graphics
%           handles returned by davinci(), then use the graphics
%           handles to modify the two patch objects that make up
%           the bracket.
px = 15;    % Position x-coordinate.
py = -.5;   % Position y-coordinate.
h = davinci( 'curly_bracket', 'Position', [px py], 'Height',     3, ...
'Width',     10, ...
'Rotation',  90 );
% Loop over the two half-brackets.
for i = 1: 2
% Extract the vertex coordinates.
vc = h.(name{i}).Vertices;
% Compute the distance of each vertex from the bracket's "Position" point.
dist = sqrt( (vc(:,1)-px).^2 + (vc(:,2)-py).^2 );
% Normalize this distance, so the distances are all in the range 0 to 1.
dist = dist ./ max(dist(:));