Drawing Program
Lab 02 Core Exercise HIT3172
 All Classes Functions Variables
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Shape Class Reference

#include <Shape.h>

Inheritance diagram for Shape:
Ellipse Line Rectangle

Public Member Functions

 Shape ()
color get_color ()
color get_highlight_color ()
point2d get_position ()
int get_width ()
int get_height ()
float get_x ()
float get_y ()
void set_color (color)
void set_highlight_color (color)
void set_position (point2d)
void set_width (int)
void set_height (int)
void set_x (float)
void set_y (float)
bool is_at (point2d)
virtual void draw ()=0
virtual void highlight ()=0

Protected Member Functions

void calculate_highlight_color ()

Protected Attributes

color _color
color _highlight_color
point2d _position
int _width
int _height

Detailed Description

The Shape class is a generic class that all specific shapes in the Drawing program inherit their basic attributes from, so that colour, width, height and position is all handled by the Shape class once and any subclasses only need to implement the abstract draw and highlight methods. Data fields are marked as protected so that they can be directly accessed by any subclasses

Constructor & Destructor Documentation

Shape::Shape ( )

Shape constructor initialises data members

Member Function Documentation

void Shape::calculate_highlight_color ( )
protected

Highlight colour calculation method

This method changes the highlight colour to be a darker version of the Shape's fill colour

color Shape::get_color ( )

Gets the Shape's fill colour

Returns
the Shape's fill colour
int Shape::get_height ( )

Gets the height of the Shape object

Returns
the Shape's height
color Shape::get_highlight_color ( )

Gets the Shape's highlight colour

Returns
the Shape's highlight colour
point2d Shape::get_position ( )

Gets the position of the Shape object

Returns
the Shape's position
int Shape::get_width ( )

Gets the width of the Shape object

Returns
the Shape's width
float Shape::get_x ( )

Gets the x-value of the Shape's position

Returns
the x position of the Shape
float Shape::get_y ( )

Gets the y-value of the Shape's position

Returns
the y position of the Shape
bool Shape::is_at ( point2d  position)

Checks if the Shape object is at that position

This method is approximate and does only rectangular region checking

Parameters
positionposition to check for
Returns
true/false
void Shape::set_color ( color  color)

Sets the fill colour of the shape and recalculates the highlight colour

Parameters
colorthe colour to set
See Also
Shape::calculate_highlight_color
void Shape::set_height ( int  height)

Sets the height of the shape

Parameters
heightheight to set
void Shape::set_highlight_color ( color  highlight_color)

Sets the highlight colour of the shape

Will be overridden after any set_color call

Parameters
highlight_colorhighlight colour set
void Shape::set_position ( point2d  position)

Sets the position of the shape

Parameters
positionposition to set
void Shape::set_width ( int  width)

Sets the width of the shape

Parameters
widthwidth to set
void Shape::set_x ( float  x)

Sets the x position of the shape

Parameters
xx position of shape to set
void Shape::set_y ( float  y)

Sets the y position of the shape

Parameters
yy position of shape to set

Member Data Documentation

color Shape::_color
protected

Fill colour of the shape

This is needed so each object can have a independent colour that can be changed an cycled to the next colour.

int Shape::_height
protected

Height of shape

color Shape::_highlight_color
protected

Colour of the shape's highlight

This is needed so the highlight colour matches the shapes colour and is only recalculated when the colour is changed

point2d Shape::_position
protected

Position of the shape

int Shape::_width
protected

Width of shape


The documentation for this class was generated from the following files: