#include <Shape.h>
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 |
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
Shape::Shape | ( | ) |
Shape constructor initialises data members
|
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_highlight_color | ( | ) |
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
position | position to check for |
void Shape::set_color | ( | color | color | ) |
Sets the fill colour of the shape and recalculates the highlight colour
color | the colour to set |
void Shape::set_height | ( | int | height | ) |
Sets the height of the shape
height | height 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
highlight_color | highlight colour set |
void Shape::set_position | ( | point2d | position | ) |
Sets the position of the shape
position | position to set |
void Shape::set_width | ( | int | width | ) |
Sets the width of the shape
width | width to set |
void Shape::set_x | ( | float | x | ) |
Sets the x position of the shape
x | x position of shape to set |
void Shape::set_y | ( | float | y | ) |
Sets the y position of the shape
y | y position of shape to set |
|
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.
|
protected |
Height of shape
|
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
|
protected |
Position of the shape
|
protected |
Width of shape