* scm/beam.scm (check-slope-callbacks): check sign of slope.
[lilypond.git] / lily / box.cc
blob97bbbb905bb9c6018b684152231c9e0e35dc56fb
1 /*
2 box.cc -- implement Box
4 source file of the GNU LilyPond music typesetter
6 (c) 1996--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
9 #include "box.hh"
10 #include "array.hh"
11 #include "axes.hh"
13 void
14 Box::translate (Offset o)
16 for (Axis i=X_AXIS; i < NO_AXES; incr (i))
17 interval_a_[i] += o[i];
20 void
21 Box::unite (Box b)
23 for (Axis i=X_AXIS; i < NO_AXES; incr (i))
24 interval_a_[i].unite (b[i]);
27 /**
28 Initialize to empty.
30 Box::Box ()
34 void
35 Box::set_empty ()
37 interval_a_[X_AXIS].set_empty ();
38 interval_a_[Y_AXIS].set_empty ();
41 Box::Box (Interval ix, Interval iy)
43 x () = ix;
44 y () = iy;
47 Interval &
48 Box::operator[] (Axis a)
50 return interval_a_[a];
53 Interval
54 Box::operator[] (Axis a)const
56 return interval_a_[a];
59 void
60 Box::scale (Real s)
62 interval_a_[X_AXIS] *= s;
63 interval_a_[Y_AXIS] *= s;
66 void
67 Box::add_point (Offset o)
69 interval_a_[X_AXIS].add_point (o[X_AXIS]);
70 interval_a_[Y_AXIS].add_point (o[Y_AXIS]);
73 Offset
74 Box::center () const
76 return Offset (interval_a_[X_AXIS].center (),
77 interval_a_[Y_AXIS].center ());
79 void
80 Box::widen (Real x, Real y)
82 interval_a_[X_AXIS].widen (x);
83 interval_a_[Y_AXIS].widen (y);