diff options
author | Karl Berry <karl@freefriends.org> | 2022-02-27 23:41:11 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2022-02-27 23:41:11 +0000 |
commit | 8027f287eb46d487a0e379911bdbc4d6c2bf44e4 (patch) | |
tree | b6e3aeebab3f5c2560ae1ab892b76cca269eb05e /Master/texmf-dist/asymptote/plain_picture.asy | |
parent | a4855ce49e2101557c17547c2d22594e1b2a215c (diff) |
asymptote 2.78 support files
git-svn-id: svn://tug.org/texlive/trunk@62265 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/asymptote/plain_picture.asy')
-rw-r--r-- | Master/texmf-dist/asymptote/plain_picture.asy | 118 |
1 files changed, 59 insertions, 59 deletions
diff --git a/Master/texmf-dist/asymptote/plain_picture.asy b/Master/texmf-dist/asymptote/plain_picture.asy index c0c189ee691..13619e80aba 100644 --- a/Master/texmf-dist/asymptote/plain_picture.asy +++ b/Master/texmf-dist/asymptote/plain_picture.asy @@ -59,10 +59,10 @@ struct coords3 { } } } - + // scaleT and Legend <<< typedef real scalefcn(real x); - + struct scaleT { scalefcn T,Tinv; bool logarithmic; @@ -86,7 +86,7 @@ scaleT operator init() scaleT S=scaleT(identity,identity); return S; } - + typedef void boundRoutine(); struct autoscaleT { @@ -97,11 +97,11 @@ struct autoscaleT { bool automin=false, automax=false; bool automin() {return automin && scale.automin;} bool automax() {return automax && scale.automax;} - + real T(real x) {return postscale.T(scale.T(x));} scalefcn T() {return scale.logarithmic ? postscale.T : T;} real Tinv(real x) {return scale.Tinv(postscale.Tinv(x));} - + autoscaleT copy() { autoscaleT dest=new autoscaleT; dest.scale=scale.copy(); @@ -120,7 +120,7 @@ struct ScaleT { autoscaleT x; autoscaleT y; autoscaleT z; - + ScaleT copy() { ScaleT dest=new ScaleT; dest.set=set; @@ -240,15 +240,15 @@ struct picture { // <<<1 return b; } } - + bounds bounds; bounds3 bounds3; - + // Other Fields <<<2 // Transform to be applied to this picture. transform T; transform3 T3; - + // The internal representation of the 3D user bounds. private pairOrTriple umin, umax; private bool usetx, usety, usetz; @@ -267,14 +267,14 @@ struct picture { // <<<1 // Fixed unitsizes in the x y, and z directions; zero means use // xsize, ysize, and zsize. real xunitsize=0, yunitsize=0, zunitsize=0; - + // If true, the x and y directions must be scaled by the same amount. bool keepAspect=true; // A fixed scaling transform. bool fixed; transform fixedscaling; - + // Init and erase <<<2 void init() { umin.init(); @@ -283,7 +283,7 @@ struct picture { // <<<1 T3=identity(4); } init(); - + // Erase the current picture, retaining bounds. void clear() { nodes.delete(); @@ -300,7 +300,7 @@ struct picture { // <<<1 scale=new ScaleT; init(); } - + // Empty <<<2 bool empty2() { return nodes.length == 0; @@ -313,7 +313,7 @@ struct picture { // <<<1 bool empty() { return empty2() && empty3(); } - + // User min/max <<<2 pair userMin2() {return bounds.userMin(); } pair userMax2() {return bounds.userMax(); } @@ -373,27 +373,27 @@ struct picture { // <<<1 umin.x=x; usetx=true; } - + void userMiny3(real y) { umin.y=y; usety=true; } - + void userMinz3(real z) { umin.z=z; usetz=true; } - + void userMaxx3(real x) { umax.x=x; usetx=true; } - + void userMaxy3(real y) { umax.y=y; usety=true; } - + void userMaxz3(real z) { umax.z=z; usetz=true; @@ -409,7 +409,7 @@ struct picture { // <<<1 void userMaxy(real y) { userMaxy2(y); userMaxy3(y); } void userMinz(real z) = userMinz3; void userMaxz(real z) = userMaxz3; - + void userCorners3(triple c000, triple c001, triple c010, triple c011, triple c100, triple c101, triple c110, triple c111) { umin.x = min(c000.x,c001.x,c010.x,c011.x,c100.x,c101.x,c110.x,c111.x); @@ -419,7 +419,7 @@ struct picture { // <<<1 umax.y = max(c000.y,c001.y,c010.y,c011.y,c100.y,c101.y,c110.y,c111.y); umax.z = max(c000.z,c001.z,c010.z,c011.z,c100.z,c101.z,c110.z,c111.z); } - + // Cache the current user-space bounding box x coodinates void userBoxX3(real min, real max, binop m=min, binop M=max) { if (usetx) { @@ -462,7 +462,7 @@ struct picture { // <<<1 userBoxY3(min.y,max.y); userBoxZ3(min.z,max.z); } - + // Add drawer <<<2 void add(drawerBound d, bool exact=false, bool above=true) { uptodate=false; @@ -472,7 +472,7 @@ struct picture { // <<<1 else nodes.insert(0,node(d)); } - + // Faster implementation of most common case. void addExactAbove(drawerBound d) { uptodate=false; @@ -518,13 +518,13 @@ struct picture { // <<<1 bounds.addPoint(user,truesize); //userBox(user,user); } - + // Add a point to the sizing, accounting also for the size of the pen. void addPoint(pair user, pair truesize=0, pen p) { addPoint(user,truesize+min(p)); addPoint(user,truesize+max(p)); } - + void addPoint(triple user, triple truesize=(0,0,0)) { bounds3.point.push(user,truesize); userBox3(user,user); @@ -618,7 +618,7 @@ struct picture { // <<<1 } void append(coords3 point, coords3 min, coords3 max, transform3 t, - bounds3 bounds) + bounds3 bounds) { // Add the coord info to this picture. if(t == identity4) { @@ -638,7 +638,7 @@ struct picture { // <<<1 point.push(t,bounds.max,bounds.max,bounds.max); } } - + // Scaling and Fit <<<2 // Returns the transform for turning user-space pairs into true-space pairs. transform scaling(real xsize, real ysize, bool keepAspect=true, @@ -660,9 +660,9 @@ struct picture { // <<<1 return identity(4); coords3 Coords; - + append(Coords,Coords,Coords,T3,bounds3); - + real sx; if(xunitsize == 0) { if(xsize != 0) sx=calculateScaling("x",Coords.x,xsize,warn); @@ -709,7 +709,7 @@ struct picture { // <<<1 triple m, triple M) { frame f; for(node3 n : nodes3) { - xasyKEY(n.key); + xasyKEY(nodes3[0].key); n.d(f,t,T0,pic,P,m,M); } return f; @@ -757,7 +757,7 @@ struct picture { // <<<1 frame f=fit(fixedscaling); pair d=size(f); static real epsilon=100*realEpsilon; - if(d.x > xsize*(1+epsilon)) + if(d.x > xsize*(1+epsilon)) warning("xlimit","frame exceeds xlimit: "+(string) d.x+" > "+ (string) xsize); if(d.y > ysize*(1+epsilon)) @@ -765,7 +765,7 @@ struct picture { // <<<1 (string) ysize); return f; } - + // Calculate additional scaling required if only an approximate picture // size estimate is available. transform scale(frame f, real xsize=this.xsize, real ysize=this.ysize, @@ -836,24 +836,24 @@ struct picture { // <<<1 bool keepAspect=this.keepAspect, bool warn=true) { return min(calculateTransform(xsize,ysize,keepAspect,warn)); } - + pair max(real xsize=this.xsize, real ysize=this.ysize, bool keepAspect=this.keepAspect, bool warn=true) { return max(calculateTransform(xsize,ysize,keepAspect,warn)); } - + triple min3(real xsize=this.xsize3, real ysize=this.ysize3, real zsize=this.zsize3, bool keepAspect=this.keepAspect, bool warn=true, projection P) { return min(calculateTransform3(xsize,ysize,zsize,keepAspect,warn,P)); } - + triple max3(real xsize=this.xsize3, real ysize=this.ysize3, real zsize=this.zsize3, bool keepAspect=this.keepAspect, bool warn=true, projection P) { return max(calculateTransform3(xsize,ysize,zsize,keepAspect,warn,P)); } - + // More Fitting <<<2 // Returns the 2D picture fit to the requested size. frame fit2(real xsize=this.xsize, real ysize=this.ysize, @@ -880,7 +880,7 @@ struct picture { // <<<1 fitter(prefix,this,format,xsize,ysize,keepAspect,view,options,script, light,P); } - + // Fit a 3D picture. frame fit3(projection P=currentprojection) { if(settings.render == 0) return fit(P); @@ -895,7 +895,7 @@ struct picture { // <<<1 // In case only an approximate picture size estimate is available, return the // fitted frame slightly scaled (including labels and true size distances) - // so that it precisely meets the given size specification. + // so that it precisely meets the given size specification. frame scale(real xsize=this.xsize, real ysize=this.ysize, bool keepAspect=this.keepAspect) { frame f=fit(xsize,ysize,keepAspect); @@ -905,7 +905,7 @@ struct picture { // <<<1 } // Copying <<<2 - + // Copies enough information to yield the same userMin/userMax. void userCopy2(picture pic) { userMinx2(pic.userMin2().x); @@ -921,12 +921,12 @@ struct picture { // <<<1 usety=pic.usety; usetz=pic.usetz; } - + void userCopy(picture pic) { userCopy2(pic); userCopy3(pic); } - + // Copies the drawing information, but not the sizing information into a new // picture. Fitting this picture will not scale as the original picture would. picture drawcopy() { @@ -954,14 +954,14 @@ struct picture { // <<<1 dest.uptodate=uptodate; dest.bounds=bounds.copy(); dest.bounds3=bounds3.copy(); - + dest.xsize=xsize; dest.ysize=ysize; dest.xsize3=xsize; dest.ysize3=ysize3; dest.zsize3=zsize3; dest.keepAspect=keepAspect; dest.xunitsize=xunitsize; dest.yunitsize=yunitsize; dest.zunitsize=zunitsize; dest.fixed=fixed; dest.fixedscaling=fixedscaling; - + return dest; } @@ -984,7 +984,7 @@ struct picture { // <<<1 dest.uptodate=uptodate; dest.bounds=bounds.transformed(t); dest.bounds3=bounds3.copy(); - + dest.bounds.exact=false; dest.xsize=xsize; dest.ysize=ysize; @@ -993,7 +993,7 @@ struct picture { // <<<1 dest.xunitsize=xunitsize; dest.yunitsize=yunitsize; dest.zunitsize=zunitsize; dest.fixed=fixed; dest.fixedscaling=fixedscaling; - + return dest; } @@ -1007,7 +1007,7 @@ struct picture { // <<<1 // objects added to it that should not be included in this picture. if(src == this) abort("cannot add picture to itself"); - + uptodate=false; picture srcCopy=src.drawcopy(); @@ -1018,7 +1018,7 @@ struct picture { // <<<1 add(f,srcCopy.fit(t,T*srcCopy.T,m,M),group,filltype,above); })); } - + if(srcCopy.nodes3.length > 0) { nodes3.push(node3(new void(frame f, transform3 t, transform3 T3, picture pic, projection P, triple m, triple M) @@ -1026,13 +1026,13 @@ struct picture { // <<<1 add(f,srcCopy.fit3(t,T3*srcCopy.T3,pic,P,m,M),group,above); })); } - + legend.append(src.legend); - + if(src.usetx) userBoxX3(src.umin.x,src.umax.x); if(src.usety) userBoxY3(src.umin.y,src.umax.y); if(src.usetz) userBoxZ3(src.umin.z,src.umax.z); - + bounds.append(srcCopy.T, src.bounds); //append(bounds.point,bounds.min,bounds.max,srcCopy.T,src.bounds); append(bounds3.point,bounds3.min,bounds3.max,srcCopy.T3,src.bounds3); @@ -1087,7 +1087,7 @@ void size3(picture pic=currentpicture, real x, real y=x, real z=y, pic.size3(x,y,z,keepAspect); } -void unitsize(picture pic=currentpicture, real x, real y=x, real z=y) +void unitsize(picture pic=currentpicture, real x, real y=x, real z=y) { pic.unitsize(x,y,z); } @@ -1113,14 +1113,14 @@ pair min(picture pic, bool user=false) pair z=pic.min(t); return user ? inverse(t)*z : z; } - + pair max(picture pic, bool user=false) { transform t=pic.calculateTransform(); pair z=pic.max(t); return user ? inverse(t)*z : z; } - + pair size(picture pic, bool user=false) { transform t=pic.calculateTransform(); @@ -1132,7 +1132,7 @@ pair size(picture pic, bool user=false) } // Frame Alignment <<< -pair rectify(pair dir) +pair rectify(pair dir) { real scale=max(abs(dir.x),abs(dir.y)); if(scale != 0) dir *= 0.5/scale; @@ -1161,13 +1161,13 @@ path[] align(path[] g, transform t=identity(), pair position, } // Returns a transform for aligning frame f in the direction align -transform shift(frame f, pair align) +transform shift(frame f, pair align) { return shift(align-point(f,-align)); } // Returns a copy of frame f aligned in the direction align -frame align(frame f, pair align) +frame align(frame f, pair align) { return shift(f,align)*f; } @@ -1448,7 +1448,7 @@ void clip(picture pic=currentpicture, path[] g, bool stroke=false, } void beginclip(picture pic=currentpicture, path[] g, bool stroke=false, - pen fillrule=currentpen, bool copy=true) + pen fillrule=currentpen, bool copy=true) { if(copy) g=copy(g); @@ -1505,7 +1505,7 @@ void filloutside(picture pic=currentpicture, path[] g, pen p=currentpen, pic.addPath(g); } -// Use a fixed scaling to map user coordinates in box(min,max) to the +// Use a fixed scaling to map user coordinates in box(min,max) to the // desired picture size. transform fixedscaling(picture pic=currentpicture, pair min, pair max, pen p=nullpen, bool warn=false) @@ -1671,7 +1671,7 @@ void begin(picture pic=currentpicture, string name, string id="", void end(picture pic=currentpicture) { if(!latex() || !pdf()) return; - tex(pic,"\end{ocg}"); + tex(pic,"\end{ocg}%"); layer(pic); } |