]> git.donarmstrong.com Git - lilypond.git/blob - src/paper.cc
release: 0.0.15
[lilypond.git] / src / paper.cc
1 #include <math.h>
2 #include "misc.hh"
3 #include "paper.hh"
4 #include "debug.hh"
5 #include "lookup.hh"
6 #include "dimen.hh"
7 #include "textdb.hh"
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(Real d)
16 {
17     return whole_width * pow(geometric_, log2(d));
18 }
19
20 Real
21 Paperdef::rule_thickness()const
22 {
23     return convert_dimen(0.4, "pt");
24 }
25
26 Paperdef::Paperdef(Lookup *l)
27 {
28     lookup_ = l;
29
30     linewidth = convert_dimen(15,"cm");         // in cm for now
31     whole_width = 8 * note_width();
32     geometric_ = sqrt(2);
33 }
34
35 Paperdef::~Paperdef()
36 {
37     delete lookup_;
38 }
39
40 void
41 Paperdef::set(Lookup*l)
42 {
43     assert(l != lookup_);
44     delete lookup_;
45     lookup_ = l;
46 }
47
48 Real
49 Paperdef::interline() const
50 {
51     return lookup_->ball(4).dim.y.length();
52 }
53
54 Real
55 Paperdef::internote() const
56 {
57     return lookup_->internote();
58 }
59 Real
60 Paperdef::note_width()const
61 {
62     return lookup_->ball(4).dim.x.length( );
63 }
64 Real
65 Paperdef::standard_height() const
66 {
67     return convert_dimen(20,"pt");
68 }
69
70 void
71 Paperdef::print() const
72 {
73 #ifndef NPRINT
74     mtor << "Paper {width: " << print_dimen(linewidth);
75     mtor << "whole: " << print_dimen(whole_width);
76     mtor << "out: " <<outfile;
77     mtor << "}\n";
78 #endif
79 }