]> git.donarmstrong.com Git - lilypond.git/blob - src/paper.cc
release: 0.0.9
[lilypond.git] / src / paper.cc
1 #include <math.h>
2
3 #include "paper.hh"
4 #include "debug.hh"
5 #include "lookup.hh"
6 #include "dimen.hh"
7 #include "textdb.hh"
8
9 double log2(double x) {
10     return log(x)  /log(2.0);
11 }
12
13
14 // golden ratio
15 const Real PHI = (1+sqrt(5))/2;
16
17 // see  Roelofs, p. 57
18 Real
19 Paperdef::duration_to_dist(Real d)
20 {
21     return whole_width * pow(geometric_, log2(d));
22 }
23 Real
24 Paperdef::rule_thickness()const
25 {
26     return convert_dimen(0.4, "pt");
27 }
28 Paperdef::Paperdef()
29 {
30     lookup_ = new Lookup();
31     parse();
32     linewidth = convert_dimen(15,"cm");         // in cm for now
33     whole_width= 8*note_width();
34     geometric_ = PHI;
35 }
36
37 void 
38 Paperdef::parse()
39 {
40     Text_db symini("symbol.ini");
41
42     
43     while (!symini.eof()) {
44         
45          Text_record  r(  symini++);
46         
47          if  (r[0] == "symboltables")
48              lookup_->parse(symini);     
49     }
50 }
51
52 Paperdef::~Paperdef()
53 {
54     delete lookup_;
55 }
56
57 Real
58 Paperdef::interline() const
59 {
60     return lookup_->ball(4).dim.y.length();
61 }
62 Real
63 Paperdef::note_width()const
64 {
65     return lookup_->ball(4).dim.x.length( );
66 }
67 Real
68 Paperdef::standard_height() const
69 {
70     return convert_dimen(20,"pt");
71 }
72
73 void
74 Paperdef::print() const
75 {
76 #ifndef NPRINT
77     mtor << "Paper {width: " << print_dimen(linewidth);
78     mtor << "whole: " << print_dimen(whole_width);
79     mtor << "out: " <<outfile;
80     mtor << "}\n";
81 #endif
82 }