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