-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLine2D.hpp
More file actions
48 lines (40 loc) · 1.48 KB
/
Copy pathLine2D.hpp
File metadata and controls
48 lines (40 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#pragma once
#include "Color.hpp"
#include "Point2D.hpp"
#include "Window.hpp"
namespace CGF
{
////////////////////////////////////////////////////////////////////////////////
/*!
@class Line2D
@brief Simple 2D line class
*/
////////////////////////////////////////////////////////////////////////////////
class Line2D
{
public:
Line2D() = default;
Line2D(const Line2D & rhs) = default;
Line2D(const Point2D & start, const Point2D & end);
Line2D(const Point2D & start, const Point2D & end, const Color & clr);
Line2D & operator = (const Line2D & rhs) = default;
virtual ~Line2D() = default;
// Getters and setters
Point2D GetStartPoint() const { return mStartPoint; }
Point2D GetEndPoint() const { return mEndPoint; }
Color GetColor() const { return mColor; }
void SetStartPoint(const Point2D & start) { mStartPoint = start; }
void SetEndPoint(const Point2D & end) { mEndPoint = end; }
void SetColor(const Color & c) { mColor = c; }
void DrawDDA(const Window & window) const;
void DrawBresenham(const Window & window) const;
private:
// Internal use
void DrawDDAFracM(float x0, float y0, float x1, float y1, float mAbs, const Window & window) const;
void DrawDDALargeM(float x0, float y0, float x1, float y1, float mInv, const Window & window) const;
void DrawBresFracM(int x0, int y0, int x1, int y1, const Window & window) const;
void DrawBresLargeM(int x0, int y0, int x1, int y1, const Window & window) const;
Point2D mStartPoint, mEndPoint;
Color mColor;
};
} // namespace CGF