2007年6月19日星期二

Asymptote学习系列(11)

数据类型(续):
 
framepicture
 
frame 是用PostScript坐标系的画布。通常不会直接用到它,而会使用相同功能的picture。一些常用函数包括:
bool empty(frame f)
      f是否为空
pair min(frame f)
      返回f的(left,bottom)
pair max(frame f)
      返回f的(right,top)
void add(frame dest, frame src);
void prepend(frame dest, frame src);
frame align(frame f, pair align);
picture 是在模块'plain'中定义的高层结构,用来提供以用户坐标下的画布。有个缺省的picture是currentpicture ,所有命令的缺省picture参数都是这个currentpicture。前面介绍的 sizeunitsize函数的原型是:
void size(picture pic=currentpicture, real x, real y=x,bool keepAspect=Aspect);
void unitsize(picture pic=currentpicture, real x, real y=x);
其中,若x与y均为0,则会把它当作PostScript坐标系,此时,把pic变换到最后的输出frame时用的是单位变换。若x或y中有一个为0,则不会在这个方向上作限制,它会用与另一个方向相同的大小作变换。若 keepAspect 为 Aspect 或 true 的话,则在x和y方向作协同变换,这样,最后的picture在x方向不会超过x,以及在y方向上不会超过y;若 keepAspect 为 IgnoreAspect 或 false 的话,则picture会在x和y方向上同时放缩,从而最后的picture宽为x,高为y。
还有一些常用的函数包括:
 
void size(picture pic=currentpicture, real xsize, real ysize,pair min, pair max);
        这个函数的作用是重新计算pic中的放缩,使得它满足把box(min,max)中的区域变为xsize宽,ysize长。
transform fixedscaling(picture pic=currentpicture, pair min,pair max, pen p=nullpen);
        这个函数
void shipout(string prefix=defaultfilename, picture pic,frame preamble=patterns,orientation orientation=orientation,string format="", bool wait=NoWait, bool view=true);
void shipout(string prefix=defaultfilename,orientation orientation=orientation,string format="", bool wait=NoWait, bool view=true);
        这两个函数可以把pic放入preamble中,并且写入文件prefix中,其中的orientation的取值包括:PortraitLandscapeSeascape UpsideDown
frame pic.fit(real xsize=pic.xsize, real ysize=pic.ysize,bool keepAspect=pic.keepAspect);
frame pic.scale(real xsize=this.xsize, real ysize=this.ysize,bool keepAspect=this.keepAspect);
        这两个函数用于显式地把pic映射到frame中去。
frame bbox(picture pic=currentpicture, real xmargin=0,real ymargin=xmargin, pen p=currentpen,filltype filltype=NoFill);
        这个函数与前两个函数的不同之处在于,它同时还画边框。其中的参数filltype可以设为:
FillDraw Fill with the pen used to draw the boundary.
FillDraw(real xmargin=0, real ymargin=xmargin, pen p=nullpen)
        If p is nullpen, fill with the pen used to draw the boundary; otherwise fill with pen p. An optional margin of xmargin and ymargin can be specified.
Fill Fill with the drawing pen.
Fill(real xmargin=0, real ymargin=xmargin, pen p=nullpen)
        If p is nullpen, fill with the drawing pen; otherwise fill with pen p.An optional margin of xmargin and ymargin can be specified.NoFill Do not fill.
Draw Draw only the boundary.
Draw(real xmargin=0, real ymargin=xmargin, pen p=nullpen)
        If p is nullpen, draw the boundary with the drawing pen; otherwise draw with pen p. An optional margin of xmargin and ymargin can be specified.
UnFill Clip the region.
UnFill(real xmargin=0, real ymargin=xmargin
        Clip the region and surrounding margins xmargin and ymargin.
RadialShade(pen penc, pen penr)
        Fill varying radially from penc at the center of the bounding box to penr at the edge.
 
pair min(picture pic);
pair max(picture pic);
        用于给出pic和边界
pair point(picture pic=currentpicture, pair dir);
        用来计算以pic的中心为起点,方向在dir的线交pic的边界的坐标。
pair truepoint(picture pic=currentpicture, pair dir);
pair framepoint(picture pic=currentpicture, pair dir);
        这两个函数与前面的point类似,framepoint返回的是最后的PostScript坐标。
void add(picture src, bool group=true,filltype filltype=NoFill, bool put=Above);
void add(picture dest, picture src, bool group=true,filltype filltype=NoFill, bool put=Above);
void add(picture dest, picture src, pair position, bool group=true,filltype filltype=NoFill, bool put=Above);
void add(picture src, pair position, bool group=true,filltype filltype=NoFill, bool put=Above);
void add(picture dest=currentpicture, frame src, pair position=0,bool group=true, filltype filltype=NoFill,bool put=Above);
void add(picture dest=currentpicture, frame src, pair position,pair align, bool group=true, filltype filltype=NoFill,bool put=Above);
        这些函数把src放入dest或currentpicture中。
void attach(picture dest=currentpicture, frame src,pair position=0, bool group=true,filltype filltype=NoFill, bool put=Above);
void attach(picture dest=currentpicture, frame src,pair position=0, pair align, bool group=true,filltype filltype=NoFill, bool put=Above);
        把src放入dest,同时调整dest的大小
path box(frame f, Label L="", real xmargin=0,real ymargin=xmargin, pen p=currentpen,filltype filltype=NoFill, bool put=Above);
path ellipse(frame f, Label L="", real xmargin=0,real ymargin=xmargin, pen p=currentpen,filltype filltype=NoFill, bool put=Above);
void box(picture pic=currentpicture, Label L,real xmargin=0, real ymargin=xmargin, pen p=currentpen,filltype filltype=NoFill, bool put=Above);
        用来在Label,frame或pic周围画一个矩形或椭圆。
void erase(picture pic=currentpicture);
save().
restore().
        用来消除,保存,恢复pic的环境
还有更多的函数,都定义在模块plain中。
 
在pic中,你还可以直接插入PostScript命令和tex命令:
void postscript(picture pic=currentpicture, string s);
void postscript(picture pic=currentpicture, string s, pair min,pair max)
void tex(picture pic=currentpicture, string s);
void tex(picture pic=currentpicture, string s, pair min, pair max)
 
 
--
一步一步教你从互联网赚钱 http://www.zqzn.com/index.asp?rid=key480769
投资理财 http://li-cai.blogspot.com/

没有评论: