Figure Asymptote generalities -- 089

Figure generalities 089 Generated with Asymptote

Show generalities/fig0890.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Examples 2D | Generalities
Tags : #Basis | #Deferred drawing | #Arrows/Bars | #Labelmargin | #Margin | #Picture

//From documentation of Asymptote
size(6cm, 0);

void distance(picture pic=currentpicture, pair A, pair B, Label L="", real n=0, pen p=currentpen)
{
  real d=3mm;
  guide g=A--B;
  transform T=shift(-n*d*unit(B-A)*I);
  pic.add(new void(frame f, transform t) {
    picture opic;
    guide G=T*t*g;
    draw(opic, G, p, Arrows(NoFill), Bars, PenMargins);
    label(opic, L, midpoint(G), UnFill(1));
    add(f, opic.fit());
  });
  pic.addBox(min(g), max(g), T*min(p), T*max(p));
}

pair A=(0, 0), B=(3, 3);

dot(A);
dot(B);
distance(A, B, Label("$\ell$", Rotate(dir(A--B))), 1);