lilypond-1.1.31
[lilypond.git] / src / paper-def.cc
blobb49a53fc8e488298454cf5139f0b24016449550b
1 #include <math.h>
2 #include "misc.hh"
3 #include "paper-def.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 Paper_def::duration_to_dist(Moment d)
17 if (!d)
18 return 0;
20 return whole_width * pow(geometric_, log_2(d));
23 Real
24 Paper_def::rule_thickness()const
26 return 0.4 PT;
29 Paper_def::Paper_def(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);
35 outfile = "lelie.out";
38 Paper_def::~Paper_def()
40 delete lookup_p_;
42 Paper_def::Paper_def(Paper_def const&s)
44 lookup_p_ = new Lookup(*s.lookup_p_);
45 geometric_ = s.geometric_;
46 whole_width = s.whole_width;
47 outfile = s.outfile;
48 linewidth = s.linewidth;
51 void
52 Paper_def::set(Lookup*l)
54 assert(l != lookup_p_);
55 delete lookup_p_;
56 lookup_p_ = l;
59 Real
60 Paper_def::interline() const
62 return lookup_p_->ball(4).dim.y.length();
65 Real
66 Paper_def::internote() const
68 return lookup_p_->internote();
70 Real
71 Paper_def::note_width()const
73 return lookup_p_->ball(4).dim.x.length( );
75 Real
76 Paper_def::standard_height() const
78 return 20 PT;
81 void
82 Paper_def::print() const
84 #ifndef NPRINT
85 mtor << "Paper {width: " << print_dimen(linewidth);
86 mtor << "whole: " << print_dimen(whole_width);
87 mtor << "out: " <<outfile;
88 lookup_p_->print();
89 mtor << "}\n";
90 #endif