-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSVGStop.cpp
102 lines (84 loc) · 1.59 KB
/
SVGStop.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
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
#include "SVGStop.h"
#include "UnitHandler.h"
BSVGStop::BSVGStop()
{
}
BSVGStop::BSVGStop(BSVGStop *stop)
{
SetOffset(stop->Offset());
SetStopColor(stop->StopColor());
SetStopOpacity(stop->StopOpacity());
}
BSVGStop::BSVGStop(rgb_color color, float offset, float opacity)
{
SetStopColor(color);
SetOffset(offset);
SetStopOpacity(opacity);
}
BSVGStop::BSVGStop(uchar r, uchar g, uchar b, float offset, float opacity)
{
SetStopColor(r, g, b);
SetOffset(offset);
SetStopOpacity(opacity);
}
BSVGStop::~BSVGStop()
{
}
BSVGStop::BSVGStop(BMessage *data)
: BSVGElement(data)
{
data->FindFloat("_offset", &fOffset);
}
BArchivable *
BSVGStop::Instantiate(BMessage *data)
{
if (validate_instantiation(data, "BSVGStop"))
return new BSVGStop(data);
return NULL;
}
status_t
BSVGStop::Archive(BMessage *data, bool deep) const
{
BSVGElement::Archive(data, deep);
data->AddFloat("_offset", fOffset);
ADDREPCLASS("BSVGStop");
ADDREPTYPE(B_SVG_STOP);
return B_OK;
}
void
BSVGStop::HandleAttribute(attribute_s *attr)
{
if (!attr)
return;
if (attr->id.Compare("offset") == 0) {
float val;
UnitHandler::Handle(attr, &val, &fState, 1);
SetOffset(val);
} else {
BSVGElement::HandleAttribute(attr);
}
}
void
BSVGStop::RecreateData()
{
fHeaderData.SetTo("<stop");
AddID(fHeaderData);
fState.AddToString(&fHeaderData);
fHeaderData << " offset=\"" << fOffset << "\" />";
fFooterData.SetTo("");
}
void
BSVGStop::SetOffset(float offset)
{
fOffset = offset;
}
float
BSVGStop::Offset() const
{
return fOffset;
}
bool
BSVGStop::IsOpaque() const
{
return (fRenderState.stop_opacity.value >= 1.0);
}