p.draw(drawVertical=true);
-Surface s = Surface(pFrom=(0,-7u), pTo=(3.5u, -7u), L="Table");
+Surface s = Surface(pFrom=(0,-7u), pTo=(3.5u, -7u),
+ L=Label("Table", align=Center, embed=Shift));
s.draw();
Vector v1 = Vector((-2u, -7u), Label("$v_1$", align=E, position=EndPoint));
pen outline;
pen filla;
pen fillb;
- Label L;
+ Label label;
void operator init(pair pFrom=(0,0), pair pTo=(5mm,0), real thickness=5mm, pen outline=currentpen, pen filla=rgb(.5,.5,.5), pen fillb=rgb(.7,.7,.7), Label L="") {
this.pFrom = pFrom;
this.outline = outline;
this.filla = filla;
this.fillb = fillb;
- this.L = L;
+ this.label = L;
}
- void draw(picture pic=currentpicture, bool rotateLabel=true) {
- picture picF;
- picture picL;
- label(picL, L);
- pair pLabelSize = 1.2 * (max(picL)-min(picL));
+ void draw(picture pic=currentpicture) {
pair pDiff = pTo - pFrom;
pair pDepth = rotate(-90)*unit(pDiff)*thickness;
- path p = (0,0) -- pDiff -- (pDiff+pDepth) -- pDepth -- cycle;
- pair label_rotate=pDiff;
- if (rotateLabel == false)
- label_rotate=(1,0);
- axialshade(pic=picF, g=p, pena=filla, a=(0,0), penb=fillb,
- b=pDepth);
- draw(picF, p, outline);
- label(pic = picF,
- L = rotate(degrees(label_rotate)) * L,
- position = (pDiff+pDepth)/2);
- add(pic, picF, pFrom);
+ path p = (0, 0) -- pDiff -- (pDiff + pDepth) -- pDepth -- cycle;
+ p = shift(this.pFrom) * p;
+ axialshade(
+ pic=pic, g=p, pena=filla, a=this.pFrom,
+ penb=fillb, b=this.pFrom+pDepth);
+ draw(pic, p, outline);
+ embed e = this.label.embed;
+ if (this.label.embed == Rotate) {
+ this.label.embed = Rotate(this.pFrom - this.pTo);
+ }
+ label(pic=pic, L=this.label,
+ g=(this.pFrom+pDepth/2) -- (this.pTo+pDepth/2));
+ this.label.embed = e;
}
}