2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 1996--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
25 Box::translate (Offset o)
27 for (Axis i = X_AXIS; i < NO_AXES; incr (i))
29 interval_a_[i] += o[i];
35 for (Axis i = X_AXIS; i < NO_AXES; incr (i))
36 interval_a_[i].unite (b[i]);
42 return interval_a_[X_AXIS].length ()
43 * interval_a_[Y_AXIS].length ();
53 interval_a_[X_AXIS].set_empty ();
54 interval_a_[Y_AXIS].set_empty ();
58 Box::is_empty () const
60 return is_empty (X_AXIS) && is_empty (Y_AXIS);
64 Box::is_empty (Axis a) const
68 return interval_a_[a][LEFT] == empty[LEFT]
69 && interval_a_[a][RIGHT] == empty[RIGHT];
72 Box::Box (Interval ix, Interval iy)
79 Box::operator [] (Axis a)
81 return interval_a_[a];
85 Box::operator [] (Axis a) const
87 return interval_a_[a];
93 interval_a_[X_AXIS] *= s;
94 interval_a_[Y_AXIS] *= s;
98 Box::add_point (Offset o)
100 interval_a_[X_AXIS].add_point (o[X_AXIS]);
101 interval_a_[Y_AXIS].add_point (o[Y_AXIS]);
107 return Offset (interval_a_[X_AXIS].center (),
108 interval_a_[Y_AXIS].center ());
112 Box::widen (Real x, Real y)
114 interval_a_[X_AXIS].widen (x);
115 interval_a_[Y_AXIS].widen (y);
119 Box::intersect (Box b)
121 interval_a_[X_AXIS].intersect (b[X_AXIS]);
122 interval_a_[Y_AXIS].intersect (b[Y_AXIS]);
130 printf ("X left %4.4f right %4.4f Y down %4.4f up %4.4f\n",
131 interval_a_[X_AXIS][LEFT], interval_a_[X_AXIS][RIGHT],
132 interval_a_[Y_AXIS][DOWN], interval_a_[Y_AXIS][UP]);
135 /****************************************************************/
138 const char Box::type_p_name_[] = "ly:box?";