lab_inheritance
Insidious Inheritance
Line Class Reference

A subclass of Drawable that represents a line in 2D space. More...

#include <line.h>

Inheritance diagram for Line:
[legend]
Collaboration diagram for Line:
[legend]

Public Member Functions

 Line (const Vector2 &a, const Vector2 &b, const cs225::HSLAPixel &color)
 Constructs a new Line going from Point a to Point b. More...
 
void draw (cs225::PNG *canvas) const
 Draws the Line onto the canvas. More...
 
Vector2 a () const
 Gets starting point of the Line. More...
 
void set_a (const Vector2 &a)
 Sets the starting point of the Line. More...
 
Vector2 b () const
 Gets the ending point of the Line. More...
 
void set_b (const Vector2 &b)
 Sets the ending point of the Line. More...
 
cs225::HSLAPixel color () const
 Gets the color of the Line. More...
 
void set_color (const cs225::HSLAPixel &color)
 Sets the color of the Line. More...
 

Static Public Member Functions

static std::vector< double > linearInterpolation (const Vector2 &a, const Vector2 &b)
 

Detailed Description

A subclass of Drawable that represents a line in 2D space.

Constructor & Destructor Documentation

◆ Line()

Line::Line ( const Vector2 a,
const Vector2 b,
const cs225::HSLAPixel &  color 
)

Constructs a new Line going from Point a to Point b.

Parameters
a
b
colorof the new Line

Member Function Documentation

◆ a()

Vector2 Line::a ( ) const

Gets starting point of the Line.

Returns
the starting point of the Line

◆ b()

Vector2 Line::b ( ) const

Gets the ending point of the Line.

Returns
the ending point of the Line

◆ color()

HSLAPixel Line::color ( ) const

Gets the color of the Line.

Returns
the color of the Line

◆ draw()

void Line::draw ( cs225::PNG *  canvas) const
virtual

Draws the Line onto the canvas.

Parameters
canvas

Implements Drawable.

◆ set_a()

void Line::set_a ( const Vector2 a)

Sets the starting point of the Line.

Parameters
athe new starting point of the Line

◆ set_b()

void Line::set_b ( const Vector2 b)

Sets the ending point of the Line.

Parameters
bthe new ending point of the Line

◆ set_color()

void Line::set_color ( const cs225::HSLAPixel &  color)

Sets the color of the Line.

Parameters
colorthe new color of the Line

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