]> git.donarmstrong.com Git - lilypond.git/blob - lily/paper-def.cc
release: 0.0.40
[lilypond.git] / lily / paper-def.cc
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"
7
8
9
10 // golden ratio
11 const Real PHI = (1+sqrt(5))/2;
12
13 // see  Roelofs, p. 57
14 Real
15 Paper_def::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 Paper_def::rule_thickness()const
25 {
26     return 0.4 PT;
27 }
28
29 Paper_def::Paper_def(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     outfile = "lelie.out";
36 }
37
38 Paper_def::~Paper_def()
39 {
40     delete lookup_p_;
41 }
42 Paper_def::Paper_def(Paper_def const&s)
43 {
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;
49 }
50
51 void
52 Paper_def::set(Lookup*l)
53 {
54     assert(l != lookup_p_);
55     delete lookup_p_;
56     lookup_p_ = l;
57 }
58
59 Real
60 Paper_def::interline() const
61 {
62     return lookup_p_->ball(4).dim.y.length();
63 }
64
65 Real
66 Paper_def::internote() const
67 {
68     return lookup_p_->internote();
69 }
70 Real
71 Paper_def::note_width()const
72 {
73     return lookup_p_->ball(4).dim.x.length( );
74 }
75 Real
76 Paper_def::standard_height() const
77 {
78     return 20 PT;
79 }
80
81 void
82 Paper_def::print() const
83 {
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
91 }
92 const Lookup*
93 Paper_def::lookup_l()
94 {
95     return lookup_p_;
96 }