3 Code to generate beams for TeX
11 #include "symtable.hh"
17 Lookup::beam_element(int sidx, int widx, Real slope)
19 Symbol bs=(*symtables_)("beamslopes")->lookup("slope");
24 bs.tex = substitute_args(bs.tex,args);
27 bs.dim.x = Interval(0,width);
28 bs.dim.y = Interval(0,width*slope);
32 // ugh.. hard wired tex-code.
37 WARN << "beam steeper than 0.5 (" << s << ")\n";
41 int i = int(rint(s * 20.0));
51 Lookup::rule_symbol(Real height, Real width)
53 Symbol bs=(*symtables_)("beamslopes")->lookup("horizontal");
55 args.push(print_dimen(height));
56 args.push(print_dimen(width));
57 bs.tex = substitute_args(bs.tex,args);
58 bs.dim.x = Interval(0,width);
59 bs.dim.y = Interval(0,height);
64 Lookup::beam(Real &slope, Real width)
66 int sidx = slope_index(slope);
68 return rule_symbol(2 PT, width);
70 WARN<<"Beam too narrow. (" << print_dimen(width) <<")\n";
73 Real elemwidth = 64 PT;
78 while (elemwidth > width) {
82 Real overlap = elemwidth/4;
83 Real last_x = width - elemwidth;
85 Atom elem(beam_element(sidx, widx, slope));
90 a.translate(Offset(x-overlap, (x-overlap)*slope));
92 x += elemwidth - overlap;
95 a.translate(Offset(last_x, (last_x) * slope));
99 ret.tex = m.TeXstring();
100 ret.dim.y = Interval(0,width*slope);
101 ret.dim.x = Interval(0,width);