1 /*
2 * Copyright 2006-2008, Haiku.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 * Artur Wyszynski <harakash@gmail.com>
7 */
8
9 #include <Point.h>
10 #include <Gradient.h>
11 #include <GradientLinear.h>
12
13
14 // constructor
BGradientLinear()15 BGradientLinear::BGradientLinear()
16 {
17 fData.linear.x1 = 0.0f;
18 fData.linear.y1 = 0.0f;
19 fData.linear.x2 = 0.0f;
20 fData.linear.y2 = 0.0f;
21 fType = TYPE_LINEAR;
22 }
23
24
25 // constructor
BGradientLinear(const BPoint & start,const BPoint & end)26 BGradientLinear::BGradientLinear(const BPoint& start, const BPoint& end)
27 {
28 fData.linear.x1 = start.x;
29 fData.linear.y1 = start.y;
30 fData.linear.x2 = end.x;
31 fData.linear.y2 = end.y;
32 fType = TYPE_LINEAR;
33 }
34
35
36 // constructor
BGradientLinear(float x1,float y1,float x2,float y2)37 BGradientLinear::BGradientLinear(float x1, float y1, float x2, float y2)
38 {
39 fData.linear.x1 = x1;
40 fData.linear.y1 = y1;
41 fData.linear.x2 = x2;
42 fData.linear.y2 = y2;
43 fType = TYPE_LINEAR;
44 }
45
46
47 // Start
48 BPoint
Start() const49 BGradientLinear::Start() const
50 {
51 return BPoint(fData.linear.x1, fData.linear.y1);
52 }
53
54
55 // SetStart
56 void
SetStart(const BPoint & start)57 BGradientLinear::SetStart(const BPoint& start)
58 {
59 fData.linear.x1 = start.x;
60 fData.linear.y1 = start.y;
61 }
62
63
64 // SetStart
65 void
SetStart(float x,float y)66 BGradientLinear::SetStart(float x, float y)
67 {
68 fData.linear.x1 = x;
69 fData.linear.y1 = y;
70 }
71
72
73 // End
74 BPoint
End() const75 BGradientLinear::End() const
76 {
77 return BPoint(fData.linear.x2, fData.linear.y2);
78 }
79
80
81 // SetEnd
82 void
SetEnd(const BPoint & end)83 BGradientLinear::SetEnd(const BPoint& end)
84 {
85 fData.linear.x2 = end.x;
86 fData.linear.y2 = end.y;
87 }
88
89
90 // SetEnd
91 void
SetEnd(float x,float y)92 BGradientLinear::SetEnd(float x, float y)
93 {
94 fData.linear.x2 = x;
95 fData.linear.y2 = y;
96 }
97