2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 1996--2012 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/>.
23 Box::translate (Offset o)
25 for (Axis i = X_AXIS; i < NO_AXES; incr (i))
27 interval_a_[i] += o[i];
33 for (Axis i = X_AXIS; i < NO_AXES; incr (i))
34 interval_a_[i].unite (b[i]);
40 return interval_a_[X_AXIS].length ()
41 * interval_a_[Y_AXIS].length ();
51 interval_a_[X_AXIS].set_empty ();
52 interval_a_[Y_AXIS].set_empty ();
56 Box::is_empty () const
58 return is_empty (X_AXIS) && is_empty (Y_AXIS);
62 Box::is_empty (Axis a) const
66 return interval_a_[a][LEFT] == empty[LEFT]
67 && interval_a_[a][RIGHT] == empty[RIGHT];
70 Box::Box (Interval ix, Interval iy)
77 Box::operator [] (Axis a)
79 return interval_a_[a];
83 Box::operator [] (Axis a) const
85 return interval_a_[a];
91 interval_a_[X_AXIS] *= s;
92 interval_a_[Y_AXIS] *= s;
96 Box::add_point (Offset o)
98 interval_a_[X_AXIS].add_point (o[X_AXIS]);
99 interval_a_[Y_AXIS].add_point (o[Y_AXIS]);
105 return Offset (interval_a_[X_AXIS].center (),
106 interval_a_[Y_AXIS].center ());
110 Box::widen (Real x, Real y)
112 interval_a_[X_AXIS].widen (x);
113 interval_a_[Y_AXIS].widen (y);
117 Box::intersect (Box b)
119 interval_a_[X_AXIS].intersect (b[X_AXIS]);
120 interval_a_[Y_AXIS].intersect (b[Y_AXIS]);
128 printf ("X left %4.4f right %4.4f Y down %4.4f up %4.4f\n",
129 interval_a_[X_AXIS][LEFT], interval_a_[X_AXIS][RIGHT],
130 interval_a_[Y_AXIS][DOWN], interval_a_[Y_AXIS][UP]);
133 /****************************************************************/
135 #include "ly-smobs.icc"
137 IMPLEMENT_SIMPLE_SMOBS (Box);
138 IMPLEMENT_TYPE_P (Box, "ly:box?");
139 IMPLEMENT_DEFAULT_EQUAL_P (Box);
142 Box::mark_smob (SCM /* x */)
148 Box::print_smob (SCM /* x */, SCM p, scm_print_state *)
150 scm_puts ("#<Box>", p);