/usr/share/asymptote/three_margins.asy is in asymptote 2.15-2build2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | struct marginT3 {
path3 g;
real begin,end;
};
typedef marginT3 margin3(path3, pen);
path3 trim(path3 g, real begin, real end) {
real a=arctime(g,begin);
real b=arctime(g,arclength(g)-end);
return a <= b ? subpath(g,a,b) : point(g,a);
}
margin3 operator +(margin3 ma, margin3 mb)
{
return new marginT3(path3 g, pen p) {
marginT3 margin;
real ba=ma(g,p).begin < 0 ? 0 : ma(g,p).begin;
real bb=mb(g,p).begin < 0 ? 0 : mb(g,p).begin;
real ea=ma(g,p).end < 0 ? 0 : ma(g,p).end;
real eb=mb(g,p).end < 0 ? 0 : mb(g,p).end;
margin.begin=ba+bb;
margin.end=ea+eb;
margin.g=trim(g,margin.begin,margin.end);
return margin;
};
}
margin3 NoMargin3()
{
return new marginT3(path3 g, pen) {
marginT3 margin;
margin.begin=margin.end=0;
margin.g=g;
return margin;
};
}
margin3 Margin3(real begin, real end)
{
return new marginT3(path3 g, pen p) {
marginT3 margin;
real factor=labelmargin(p);
real w=0.5*linewidth(p);
margin.begin=begin*factor-w;
margin.end=end*factor-w;
margin.g=trim(g,margin.begin,margin.end);
return margin;
};
}
margin3 PenMargin3(real begin, real end)
{
return new marginT3(path3 g, pen p) {
marginT3 margin;
real factor=linewidth(p);
margin.begin=begin*factor;
margin.end=end*factor;
margin.g=trim(g,margin.begin,margin.end);
return margin;
};
}
margin3 DotMargin3(real begin, real end)
{
return new marginT3(path3 g, pen p) {
marginT3 margin;
real margindot(real x) {return x > 0 ? dotfactor*x : x;}
real factor=linewidth(p);
margin.begin=margindot(begin)*factor;
margin.end=margindot(end)*factor;
margin.g=trim(g,margin.begin,margin.end);
return margin;
};
}
margin3 TrueMargin3(real begin, real end)
{
return new marginT3(path3 g, pen p) {
marginT3 margin;
margin.begin=begin;
margin.end=end;
margin.g=trim(g,begin,end);
return margin;
};
}
margin3 NoMargin3=NoMargin3(),
BeginMargin3=Margin3(1,0),
Margin3=Margin3(0,1),
EndMargin3=Margin3,
Margins3=Margin3(1,1),
BeginPenMargin3=PenMargin3(0.5,-0.5),
BeginPenMargin2=PenMargin3(1.0,-0.5),
PenMargin3=PenMargin3(-0.5,0.5),
PenMargin2=PenMargin3(-0.5,1.0),
EndPenMargin3=PenMargin3,
EndPenMargin2=PenMargin2,
PenMargins3=PenMargin3(0.5,0.5),
PenMargins2=PenMargin3(1.0,1.0),
BeginDotMargin3=DotMargin3(0.5,-0.5),
DotMargin3=DotMargin3(-0.5,0.5),
EndDotMargin3=DotMargin3,
DotMargins3=DotMargin3(0.5,0.5);
|