diff options
author | Karl Berry <karl@freefriends.org> | 2013-04-07 18:19:31 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2013-04-07 18:19:31 +0000 |
commit | 752012c605d34cd943795527a9738475a6958fcc (patch) | |
tree | 4ee06acdd8333a662c2d6f6ef716235053468f55 /Master/texmf-dist/asymptote/plain_margins.asy | |
parent | 9789d09132f18a838e84f041b4b3aff28d3426ec (diff) |
texmf -> texmf-dist: start with unique dirs from texmf
git-svn-id: svn://tug.org/texlive/trunk@29712 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/asymptote/plain_margins.asy')
-rw-r--r-- | Master/texmf-dist/asymptote/plain_margins.asy | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/Master/texmf-dist/asymptote/plain_margins.asy b/Master/texmf-dist/asymptote/plain_margins.asy new file mode 100644 index 00000000000..c4522754481 --- /dev/null +++ b/Master/texmf-dist/asymptote/plain_margins.asy @@ -0,0 +1,99 @@ +struct marginT { + path g; + real begin,end; +}; + +typedef marginT margin(path, pen); + +path trim(path 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); +} + +margin operator +(margin ma, margin mb) +{ + return new marginT(path g, pen p) { + marginT 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; + }; +} + +margin NoMargin() +{ + return new marginT(path g, pen) { + marginT margin; + margin.begin=margin.end=0; + margin.g=g; + return margin; + }; +} + +margin Margin(real begin, real end) +{ + return new marginT(path g, pen p) { + marginT margin; + real factor=labelmargin(p); + margin.begin=begin*factor; + margin.end=end*factor; + margin.g=trim(g,margin.begin,margin.end); + return margin; + }; +} + +margin PenMargin(real begin, real end) +{ + return new marginT(path g, pen p) { + marginT margin; + real factor=linewidth(p); + margin.begin=(begin+0.5)*factor; + margin.end=(end+0.5)*factor; + margin.g=trim(g,margin.begin,margin.end); + return margin; + }; +} + +margin DotMargin(real begin, real end) +{ + return new marginT(path g, pen p) { + marginT margin; + real margindot(real x) {return x > 0 ? dotfactor*x : x;} + real factor=linewidth(p); + margin.begin=(margindot(begin)+0.5)*factor; + margin.end=(margindot(end)+0.5)*factor; + margin.g=trim(g,margin.begin,margin.end); + return margin; + }; +} + +margin TrueMargin(real begin, real end) +{ + return new marginT(path g, pen p) { + marginT margin; + margin.begin=begin; + margin.end=end; + margin.g=trim(g,begin,end); + return margin; + }; +} + +margin NoMargin=NoMargin(), + BeginMargin=Margin(1,0), + Margin=Margin(0,1), + EndMargin=Margin, + Margins=Margin(1,1), + BeginPenMargin=PenMargin(0.5,-0.5), + PenMargin=PenMargin(-0.5,0.5), + EndPenMargin=PenMargin, + PenMargins=PenMargin(0.5,0.5), + BeginDotMargin=DotMargin(0.5,-0.5), + DotMargin=DotMargin(-0.5,0.5), + EndDotMargin=DotMargin, + DotMargins=DotMargin(0.5,0.5); |