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);
26 Real width = convert_dimen(w,"pt");
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";
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.add(print_dimen(height));
56 args.add(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(convert_dimen(2,"pt"), width);
69 if (width < convert_dimen(2,"pt")) {
70 WARN<<"Beam too narrow.\n";
71 width = convert_dimen(2,"pt");
73 Real elemwidth = convert_dimen(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);