DGtal  1.2.0
Board/Shapes.ih
1 /* -*- mode: c++ -*- */
2 /**
3  * @file Shapes.ih
4  * @author Sebastien Fourey <http://www.greyc.ensicaen.fr/~seb>
5  * @date Feb. 2010
6  *
7  * @brief Shapes inline methods
8  */
9 /*
10  * \@copyright This File is part of the Board library which is
11  * licensed under the terms of the GNU Lesser General Public Licence.
12  * See the LICENCE file for further details.
13  */
14 
15 namespace LibBoard {
16 
17 Shape::Shape( DGtal::Color pen,
18  DGtal::Color fill,
19  double lineWidth,
20  LineStyle style,
21  const LineCap cap,
22  const LineJoin join,
23  int depthValue )
24  : _depth( depthValue ),
25  _penColor( pen ),
26  _fillColor( fill ),
27  _lineWidth( lineWidth ),
28  _lineStyle( style ),
29  _lineCap( cap ),
30  _lineJoin( join )
31 {
32 }
33 
34 Dot::Dot( double x, double y,
35  DGtal::Color color,
36  double lineWidth,
37  int depthValue )
38  : Shape( color,
39  DGtal::Color::None,
40  lineWidth, SolidStyle, RoundCap, MiterJoin, depthValue ),
41  _x( x ), _y( y )
42 {
43 }
44 
45 Line::Line( double x1, double y1, double x2, double y2,
46  DGtal::Color color,
47  double lineWidth,
48  const LineStyle style,
49  const LineCap cap,
50  const LineJoin join,
51  int depthValue )
52  : Shape( color, DGtal::Color::None, lineWidth, style, cap, join, depthValue ),
53  _x1( x1 ), _y1( y1 ), _x2( x2 ), _y2( y2 )
54 {
55 }
56 
57 
58 
59 Arrow::Arrow( double x1, double y1, double x2, double y2,
60  DGtal::Color pen,
61  DGtal::Color fill,
62  double lineWidth,
63  const LineStyle style,
64  const LineCap cap,
65  const LineJoin join,
66  int depthValue )
67  : Line( x1, y1, x2, y2, pen, lineWidth, style, cap, join, depthValue )
68 {
69  Shape::_fillColor = fill;
70 }
71 
72 Polyline::Polyline( const std::vector<Point> & points,
73  bool closed,
74  DGtal::Color pen,
75  DGtal::Color fill,
76  double lineWidth,
77  const LineStyle lineStyle,
78  const LineCap cap,
79  const LineJoin join,
80  int depthValue )
81  : Shape( pen, fill, lineWidth, lineStyle, cap, join, depthValue ),
82  _path( points, closed )
83 {
84 }
85 
86 Polyline::Polyline( const Path & path,
87  DGtal::Color pen,
88  DGtal::Color fill,
89  double lineWidth,
90  const LineStyle lineStyle,
91  const LineCap cap,
92  const LineJoin join,
93  int depthValue )
94  : Shape( pen, fill, lineWidth, lineStyle, cap, join, depthValue ),
95  _path( path )
96 {
97 }
98 
99  Polyline::Polyline( bool closed,
100  DGtal::Color pen,
101  DGtal::Color fill,
102  double lineWidth,
103  const LineStyle lineStyle,
104  const LineCap cap,
105  const LineJoin join,
106  int depthValue )
107  : Shape( pen, fill, lineWidth, lineStyle, cap, join, depthValue ),
108  _path( closed )
109 {
110 }
111 
112 Rectangle::Rectangle( double xLeft,
113  double yTop,
114  double rectWidth,
115  double rectHeight,
116  DGtal::Color pen,
117  DGtal::Color fill,
118  double lineWidth,
119  const LineStyle style,
120  const LineCap cap,
121  const LineJoin join,
122  int depthValue )
123  : Polyline( std::vector<Point>(), true, pen, fill,
124  lineWidth, style, cap, join, depthValue )
125 {
126  _path << Point( xLeft, yTop );
127  _path << Point( xLeft + rectWidth, yTop );
128  _path << Point( xLeft + rectWidth, yTop - rectHeight );
129  _path << Point( xLeft, yTop - rectHeight );
130 }
131 
132 Rectangle::Rectangle( const Rect & rect,
133  DGtal::Color pen,
134  DGtal::Color fill,
135  double lineWidth,
136  const LineStyle style,
137  const LineCap cap,
138  const LineJoin join,
139  int depthValue )
140  : Polyline( std::vector<Point>(), true, pen, fill, lineWidth, style, cap, join, depthValue ) {
141  _path << Point( rect.left, rect.top );
142  _path << Point( rect.left + rect.width, rect.top );
143  _path << Point( rect.left + rect.width, rect.top - rect.height );
144  _path << Point( rect.left, rect.top - rect.height );
145 }
146 
147 
148 
149 Image::Image( double x0, double y0, double aWidth, double aHeight,
150  std::string fileName, int depthValue, double alpha )
151  : Rectangle(x0, y0, aWidth, aHeight, DGtal::Color::None, DGtal::Color::None, 0.0, SolidStyle, RoundCap, MiterJoin, depthValue ),
152  _x0(x0), _y0(y0), _width(aWidth), _height(aHeight), _filename(fileName), _alpha (alpha)
153 {
154 }
155 
156 
157 
158 } // namespace LibBoard