-
Notifications
You must be signed in to change notification settings - Fork 0
/
SVGPath.h
134 lines (106 loc) · 3.14 KB
/
SVGPath.h
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#ifndef _SVG_PATH_H_
#define _SVG_PATH_H_
#include <String.h>
#include <GraphicsDefs.h>
#include "ObjectList.h"
#include <Shape.h>
#include <View.h>
#include "SVGDefs.h"
#include "SVGElement.h"
#include "SVGGradient.h"
#include "Matrix.h"
class BSVGView;
class BSVGPath : public BSVGElement {
public:
BSVGPath(BSVGView *parent);
BSVGPath(BSVGView *parent, const char *data);
BSVGPath(BSVGView *parent, BString data);
virtual ~BSVGPath();
BSVGPath(BMessage *data);
static BArchivable *Instantiate(BMessage *data);
virtual status_t Archive(BMessage *data, bool deep = true) const;
virtual element_t Type() { return B_SVG_PATH; };
virtual void HandleAttribute(attribute_s *attr);
virtual void FinalizeShape();
void ApplyTransformation();
virtual void RecreateData();
virtual void SetShape(BShape *shape);
BShape *Shape();
virtual BRect ShapeBounds();
BShape *TransformedShape();
virtual void CollectBounds(BRect &bounds, bool *first);
void MoveTo(BPoint to, bool relative = false);
void LineTo(BPoint to, bool relative = false);
void HLineTo(float x, bool relative = false);
void VLineTo(float y, bool relative = false);
void CurveTo(BPoint control1, BPoint control2, BPoint to, bool relative = false);
void ShortCurveTo(BPoint control, BPoint to, bool relative = false);
void QuadBezierTo(BPoint control, BPoint to, bool relative = false);
void ShortBezierTo(BPoint to, bool relative = false);
void EllipticalArcTo(BPoint radii, float rotation, bool large, bool sweep, BPoint to, bool relative = false);
static float VectorsToAngle(BPoint u, BPoint v);
void RoundArcTo(BPoint center, BPoint radii, float rotation, float theta, float deltatheta, BPoint to = BPoint(0, 0), bool connect = false);
void Close();
bool NewSubPath();
BPoint Start();
BPoint LastLocation();
BPoint LastControl();
bool LastWasCurve();
bool LastWasQuadBezier();
virtual void PrepareRendering(SVGState *inherit = NULL);
virtual void Render(BView *view);
virtual void Render(BWindow *window);
virtual void Render(BBitmap *bitmap);
// must accept child views
virtual void RenderCommon();
private:
friend class BSVGRect;
friend class BSVGEllipse;
friend class BSVGCircle;
friend class BSVGLine;
friend class BSVGPolyline;
friend class BSVGPolygon;
friend class BSVGString;
BShape fShape;
BShape fTransformedShape;
BShape *fRenderShape; // points to fShape or fTranslatedShape
bool fNewSubPath;
BPoint fStart;
BPoint fLastLocation; // the last pen position is cached
BPoint fLastControl; // the last control point for shorthands
bool fLastWasCurve; // tells us wether we can use fLastControl
bool fLastWasQuad;
void SetupView(BRect bounds);
BView *fView;
};
inline BPoint
BSVGPath::Start()
{
return fStart;
}
inline bool
BSVGPath::NewSubPath()
{
return fNewSubPath;
}
inline BPoint
BSVGPath::LastLocation()
{
return fLastLocation;
}
inline BPoint
BSVGPath::LastControl()
{
return fLastControl;
}
inline bool
BSVGPath::LastWasCurve()
{
return fLastWasCurve;
}
inline bool
BSVGPath::LastWasQuadBezier()
{
return fLastWasQuad;
}
#endif