function [] = Draw_Rect(centroid, width_height, color_index)
%function [] = Draw_Rect(centroid, width_height, color_index)
%ME323, Lab 3
%Function that draws a rectangle in the current figure, given the
%parameters of the rectangle and the color.
%Inputs:
%   centroid = the location of the centroid of the rectangle, 
%               a 2-by-1 vector containing [xloc yloc].
%   width_height = the size of the rectangle, a 2-by-1 vector containing
%               [width height] where width is the x-width, height is the
%               y-height.
%   color_index = the desired color of the rectangle, a 3-by-1 vector
%               containing [r g b] where r g and b are scaled color values
%               from 0 to 1. Thus, red is [1 0 0] and black is [0 0 0].
%Outputs:
%   none
%S. Moseley & C. Lui March 19, 2013

x_lower_left  = centroid(1) - width_height(1) / 2.0;
x_lower_right = centroid(1) + width_height(1) / 2.0;
x_upper_left  = centroid(1) - width_height(1) / 2.0;
x_upper_right = centroid(1) + width_height(1) / 2.0;

y_lower_left  = centroid(2) - width_height(2) / 2.0;
y_lower_right = centroid(2) - width_height(2) / 2.0;
y_upper_left  = centroid(2) + width_height(2) / 2.0;
y_upper_right = centroid(2) + width_height(2) / 2.0;

x_coor = [x_lower_left x_lower_right x_upper_right x_upper_left];
y_coor = [y_lower_left y_lower_right y_upper_right y_upper_left];

fill(x_coor, y_coor, color_index, 'EdgeColor', color_index);
axis equal
