flower-1.0.27
[lilypond.git] / src / paperdef.cc
blob21cc42f317af64a12f7e20234592ee6e76111267
1 #include <math.h>
2 #include "misc.hh"
3 #include "paperdef.hh"
4 #include "debug.hh"
5 #include "lookup.hh"
6 #include "dimen.hh"
10 // golden ratio
11 const Real PHI = (1+sqrt(5))/2;
13 // see Roelofs, p. 57
14 Real
15 Paperdef::duration_to_dist(Moment d)
17 if (!d)
18 return 0;
20 return whole_width * pow(geometric_, log_2(d));
23 Real
24 Paperdef::rule_thickness()const
26 return 0.4 PT;
29 Paperdef::Paperdef(Lookup *l)
31 lookup_p_ = l;
32 linewidth = 15 *CM_TO_PT; // in cm for now
33 whole_width = 8 * note_width();
34 geometric_ = sqrt(2);
37 Paperdef::~Paperdef()
39 delete lookup_p_;
41 Paperdef::Paperdef(Paperdef const&s)
43 lookup_p_ = new Lookup(*s.lookup_p_);
44 geometric_ = s.geometric_;
45 whole_width = s.whole_width;
46 outfile = s.outfile;
47 linewidth = s.linewidth;
50 void
51 Paperdef::set(Lookup*l)
53 assert(l != lookup_p_);
54 delete lookup_p_;
55 lookup_p_ = l;
58 Real
59 Paperdef::interline() const
61 return lookup_p_->ball(4).dim.y.length();
64 Real
65 Paperdef::internote() const
67 return lookup_p_->internote();
69 Real
70 Paperdef::note_width()const
72 return lookup_p_->ball(4).dim.x.length( );
74 Real
75 Paperdef::standard_height() const
77 return 20 PT;
80 void
81 Paperdef::print() const
83 #ifndef NPRINT
84 mtor << "Paper {width: " << print_dimen(linewidth);
85 mtor << "whole: " << print_dimen(whole_width);
86 mtor << "out: " <<outfile;
87 mtor << "}\n";
88 #endif