]> git.donarmstrong.com Git - lilypond.git/blob - src/paperdef.cc
21cc42f317af64a12f7e20234592ee6e76111267
[lilypond.git] / src / paperdef.cc
1 #include <math.h>
2 #include "misc.hh"
3 #include "paperdef.hh"
4 #include "debug.hh"
5 #include "lookup.hh"
6 #include "dimen.hh"
7
8
9
10 // golden ratio
11 const Real PHI = (1+sqrt(5))/2;
12
13 // see  Roelofs, p. 57
14 Real
15 Paperdef::duration_to_dist(Moment d)
16 {
17     if (!d)
18         return 0;
19     
20     return whole_width * pow(geometric_, log_2(d));
21 }
22
23 Real
24 Paperdef::rule_thickness()const
25 {
26     return 0.4 PT;
27 }
28
29 Paperdef::Paperdef(Lookup *l)
30 {
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 }
36
37 Paperdef::~Paperdef()
38 {
39     delete lookup_p_;
40 }
41 Paperdef::Paperdef(Paperdef const&s)
42 {
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;
48 }
49
50 void
51 Paperdef::set(Lookup*l)
52 {
53     assert(l != lookup_p_);
54     delete lookup_p_;
55     lookup_p_ = l;
56 }
57
58 Real
59 Paperdef::interline() const
60 {
61     return lookup_p_->ball(4).dim.y.length();
62 }
63
64 Real
65 Paperdef::internote() const
66 {
67     return lookup_p_->internote();
68 }
69 Real
70 Paperdef::note_width()const
71 {
72     return lookup_p_->ball(4).dim.x.length( );
73 }
74 Real
75 Paperdef::standard_height() const
76 {
77     return 20 PT;
78 }
79
80 void
81 Paperdef::print() const
82 {
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
89 }