]> git.donarmstrong.com Git - lilypond.git/blob - src/paper.cc
release: 0.0.30
[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 0.4 PT;
24 }
25
26 Paperdef::Paperdef(Lookup *l)
27 {
28     lookup_p_ = l;
29     linewidth = 15 *CM_TO_PT;           // in cm for now
30     whole_width = 8 * note_width();
31     geometric_ = sqrt(2);
32 }
33
34 Paperdef::~Paperdef()
35 {
36     delete lookup_p_;
37 }
38 Paperdef::Paperdef(Paperdef const&s)
39 {
40     lookup_p_ = new Lookup(*s.lookup_p_);
41     geometric_ = s.geometric_;
42     whole_width = s.whole_width;
43     outfile = s.outfile;
44     linewidth = s.linewidth;
45 }
46
47 void
48 Paperdef::set(Lookup*l)
49 {
50     assert(l != lookup_p_);
51     delete lookup_p_;
52     lookup_p_ = l;
53 }
54
55 Real
56 Paperdef::interline() const
57 {
58     return lookup_p_->ball(4).dim.y.length();
59 }
60
61 Real
62 Paperdef::internote() const
63 {
64     return lookup_p_->internote();
65 }
66 Real
67 Paperdef::note_width()const
68 {
69     return lookup_p_->ball(4).dim.x.length( );
70 }
71 Real
72 Paperdef::standard_height() const
73 {
74     return 20 PT;
75 }
76
77 void
78 Paperdef::print() const
79 {
80 #ifndef NPRINT
81     mtor << "Paper {width: " << print_dimen(linewidth);
82     mtor << "whole: " << print_dimen(whole_width);
83     mtor << "out: " <<outfile;
84     mtor << "}\n";
85 #endif
86 }