+/*
+ should move to lookup?
+ */
+Molecule
+Tuplet_bracket::make_bracket (Axis protusion_axis,
+ Real dx, Real dy, Real thick, Drul_array<Real> height,
+ Real gap,
+ Drul_array<Real> widen,
+ Drul_array<Real> shorten)
+{
+ Real len = Offset (dx,dy).length ();
+ Real gapx = dx * (gap / len);
+ Real gapy = dy * (gap / len);
+ Drul_array<Real> shortx, shorty;
+ Direction d = LEFT;
+ do {
+ shortx[d] = dx * (shorten[d] / len);
+ shorty[d] = dy * (shorten[d] / len);
+ }
+ while (flip (&d) != LEFT);
+ Axis other = other_axis (protusion_axis);
+
+ Molecule l1 = Lookup::line (thick, Offset(shortx[LEFT], shorty[LEFT]),
+ Offset ( (dx - gapx)/2, (dy - gapy)/2 ));
+
+ Molecule l2 = Lookup::line (thick, Offset((dx + gapx) / 2,(dy + gapy) / 2),
+ Offset (dx - shortx[RIGHT], dy - shorty[RIGHT]));
+
+ Offset protusion;
+ protusion[other] = -widen[LEFT];
+ protusion[protusion_axis] = height[LEFT];
+ Molecule p1 = Lookup::line (thick,
+ Offset(shortx[LEFT], shorty[LEFT]),
+ Offset(shortx[LEFT], shorty[LEFT]) + protusion);
+ protusion[other] = widen[RIGHT];
+ protusion[protusion_axis] = height[RIGHT];
+ Molecule p2 = Lookup::line (thick,
+ Offset(dx - shortx[RIGHT], dy - shorty[RIGHT]),
+ Offset(dx - shortx[RIGHT], dy - shorty[RIGHT]) + protusion);
+
+ Molecule m;
+ m.add_molecule (p1);
+ m.add_molecule (p2);
+ m.add_molecule (l1);
+ m.add_molecule (l2);
+
+ return m;
+}