-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPath.cpp
60 lines (50 loc) · 942 Bytes
/
Path.cpp
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
49
50
51
52
53
54
55
56
57
58
59
60
#include "Path.h"
#include "common.h"
Path::~Path(void)
{
delete mCurve;
delete mNext;
}
Path Path::start(coord xy)
{
return Path(xy);
}
Path* Path::line(coord next)
{
mNext = new Path(next, new BezierCurve(mXY, next));
return mNext;
}
Path* Path::horizontal(em delta)
{
return line({delta, 0});
}
Path* Path::vertical(em delta)
{
return line({0, delta});
}
Path* Path::quadratic(coord anchor, coord next)
{
mNext = new Path(next, new BezierCurve(mXY, anchor, next));
return mNext;
}
void Path::close(Path* origin)
{
mNext = new Path(origin->mXY, new BezierCurve(mXY, origin->mXY));
}
void Path::drawTo(EmBox* box)
{
for (Path* cursor = mNext; cursor; cursor = cursor->mNext)
{
if (!cursor->mCurve)
{
return;
}
cursor->mCurve->draw(box);
}
}
Path::Path(coord xy, BezierCurve* curve):
mXY(xy),
mCurve(curve),
mNext(NULL)
{
}