]> git.donarmstrong.com Git - lilypond.git/blob - lily/box.cc
*** empty log message ***
[lilypond.git] / lily / box.cc
1 /*
2   box.cc -- implement Box
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1996--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include "box.hh"
10
11 #include "array.hh"
12
13 void
14 Box::translate (Offset o)
15 {
16   for (Axis i = X_AXIS; i < NO_AXES; incr (i))
17     interval_a_[i] += o[i];
18 }
19
20 void
21 Box::unite (Box b)
22 {
23   for (Axis i = X_AXIS; i < NO_AXES; incr (i))
24     interval_a_[i].unite (b[i]);
25 }
26
27 /**
28   Initialize to empty.
29  */
30 Box::Box ()
31 {        
32 }
33
34 void
35 Box::set_empty ()
36 {
37   interval_a_[X_AXIS].set_empty ();
38   interval_a_[Y_AXIS].set_empty (); 
39 }
40
41 Box::Box (Interval ix, Interval iy)
42 {
43   x () = ix;
44   y () = iy;
45 }
46
47 Interval &
48 Box::operator[] (Axis a)
49 {
50   return interval_a_[a];
51 }
52
53 Interval
54 Box::operator[] (Axis a)const
55 {
56   return interval_a_[a];
57 }
58
59 void
60 Box::scale (Real s)
61 {
62   interval_a_[X_AXIS] *= s;
63   interval_a_[Y_AXIS] *= s;
64 }
65
66 void
67 Box::add_point (Offset o)
68 {
69   interval_a_[X_AXIS].add_point (o[X_AXIS]);
70   interval_a_[Y_AXIS].add_point (o[Y_AXIS]);  
71 }
72
73 Offset
74 Box::center () const
75 {
76   return Offset (interval_a_[X_AXIS].center (),
77                  interval_a_[Y_AXIS].center ()); 
78 }
79 void
80 Box::widen (Real x, Real y)
81 {
82   interval_a_[X_AXIS].widen (x);
83   interval_a_[Y_AXIS].widen (y);
84 }