-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSVGGradient.h
141 lines (104 loc) · 3.42 KB
/
SVGGradient.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
135
136
137
138
139
140
141
#ifndef _SVG_GRADIENT_H_
#define _SVG_GRADIENT_H_
#include <Message.h>
#include <Rect.h>
#include <Region.h>
#include <String.h>
#include <SupportDefs.h>
#include "SVGDefs.h"
#include "ObjectList.h"
#include "SVGPaintServer.h"
class BBitmap;
class BShape;
class BView;
// BSVGGradient serves as a base class for BLinearGradient and BRadialGradient
class BSVGGradient : public BSVGPaintServer {
public:
BSVGGradient(BSVGView *parent);
BSVGGradient(BSVGView *parent, BRect frame, BPoint start, BPoint end);
virtual ~BSVGGradient();
BSVGGradient(BMessage *data);
static BArchivable *Instantiate(BMessage *data);
virtual status_t Archive(BMessage *data, bool deep = true) const;
virtual void HandleAttribute(attribute_s *attr);
virtual element_t Type() { return B_SVG_GRADIENT; };
void SetVector(BPoint start, BPoint end);
void SetStart(BPoint start);
void SetEnd(BPoint end);
BPoint Start() const;
BPoint End() const;
void SetSpreadMethod(spread_t method);
spread_t SpreadMethod() const;
BSVGStop *StopAt(int index);
void AddStop(BSVGStop *stop);
bool RemoveStop(BSVGStop *stop);
BSVGStop *RemoveStopAt(int index);
int32 CountStops();
void ClearStops();
void SortStops();
virtual bool IsFullyOpaque() const;
virtual void ApplyPaint(BView *view);
virtual void ApplyPaint(BBitmap *bitmap);
private:
friend class BSVGLinearGradient;
friend class BSVGRadialGradient;
virtual void Recalculate();
virtual void PrepareRendering(SVGState *inherit);
virtual void Render(BView *view);
virtual void Render(BWindow *window);
virtual void Render(BBitmap *bitmap);
virtual void RenderCommon();
virtual BSVGElement *ResolveLink();
BPoint fStart; // these two points give us the vector
BPoint fEnd; // the gradient is drawn along
BPoint fRenderStart;
BPoint fRenderEnd;
bool fStartX;
bool fStartY;
bool fEndX;
bool fEndY;
bool fHorizontal;
spread_t fSpreadMethod;
};
class BSVGLinearGradient : public BSVGGradient
{
public:
BSVGLinearGradient(BSVGView *parent);
BSVGLinearGradient(BSVGView *parent, BRect frame, BPoint start, BPoint end);
BSVGLinearGradient(BMessage *data);
static BArchivable *Instantiate(BMessage *data);
virtual status_t Archive(BMessage *data, bool deep = true) const;
virtual void HandleAttribute(attribute_s *attr);
virtual element_t Type() { return B_SVG_LINEARGRAD; };
virtual void RecreateData();
virtual void ApplyPaint(BView *view);
virtual void ApplyPaint(BBitmap *bitmap);
private:
virtual void Recalculate();
virtual BSVGElement *ResolveLink();
BPoint fIntersections[4];
};
class BSVGRadialGradient : public BSVGGradient
{
public:
BSVGRadialGradient(BSVGView *parent);
BSVGRadialGradient(BSVGView *parent, BRect frame, BPoint start, BPoint end);
BSVGRadialGradient(BMessage *data);
static BArchivable *Instantiate(BMessage *data);
virtual status_t Archive(BMessage *data, bool deep = true) const;
virtual void HandleAttribute(attribute_s *attr);
virtual element_t Type() { return B_SVG_RADIALGRAD; };
virtual void RecreateData();
void SetFocal(BPoint focal);
BPoint Focal() const;
virtual void ApplyPaint(BView *view);
virtual void ApplyPaint(BBitmap *bitmap);
private:
virtual void Recalculate();
virtual BSVGElement *ResolveLink();
BPoint fFocal;
BPoint fRenderFocal;
bool fFocalX;
bool fFocalY;
};
#endif // GRADIENT_H_