]> git.donarmstrong.com Git - lilypond.git/blob - src/paper.cc
release: 0.0.24
[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
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     return whole_width * pow(geometric_, log_2(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_p_ = 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_p_;
38 }
39 Paperdef::Paperdef(Paperdef const&s)
40 {
41     lookup_p_ = new Lookup(*s.lookup_p_);
42     geometric_ = s.geometric_;
43     whole_width = s.whole_width;
44     outfile = s.outfile;
45     linewidth = s.linewidth;
46 }
47
48 void
49 Paperdef::set(Lookup*l)
50 {
51     assert(l != lookup_p_);
52     delete lookup_p_;
53     lookup_p_ = l;
54 }
55
56 Real
57 Paperdef::interline() const
58 {
59     return lookup_p_->ball(4).dim.y.length();
60 }
61
62 Real
63 Paperdef::internote() const
64 {
65     return lookup_p_->internote();
66 }
67 Real
68 Paperdef::note_width()const
69 {
70     return lookup_p_->ball(4).dim.x.length( );
71 }
72 Real
73 Paperdef::standard_height() const
74 {
75     return convert_dimen(20,"pt");
76 }
77
78 void
79 Paperdef::print() const
80 {
81 #ifndef NPRINT
82     mtor << "Paper {width: " << print_dimen(linewidth);
83     mtor << "whole: " << print_dimen(whole_width);
84     mtor << "out: " <<outfile;
85     mtor << "}\n";
86 #endif
87 }