《第12章FORTRAN图形操作.ppt》由会员分享,可在线阅读,更多相关《第12章FORTRAN图形操作.ppt(24页珍藏版)》请在优知文库上搜索。
1、 QWIN$MIN QWIN$MAX将坐标原点设置在物理坐标点(x,y):CALL SETVIEWORG(x,y,t)其中(x,y)为新原点的物理坐标,t为XYCOORD 结构体类型的变量。TYPE xycoord INTEGER(2)xcoord !x坐标 INTEGER(2)ycoord !y坐标END TYPE xycoord 1设置颜色result=SETCOLORRGB(color)result=SETBKCOLORRGB(color)result=SETTEXTCOLORRGB(color)color为Integer(4)型,一般用16进制表示颜色取值。要使设置的背景色发生作用,须
2、使用CLEARSCREEN函数清空目标区域,填充样式(FillMask)是横线、竖线和斜线等按一定规律重复出现而形成的图案,是构成填充部分的基本图元。位元素位元素其中(x,y)为INTEGER(2)型,为视口坐标系中目标像素的坐标;(wx.wy)为 REAL(8)型,为视窗坐标系中目标像素的坐标。xy3sinUSE MSFLIB INTEGER(2)statusTYPE(xycoord)xystatus=SETCOLORRGB(#FFFFFF)CALL MOVETO(INT2(80),INT2(50),xy)status=LINETO(INT2(240),INT2(150)CALL SETLI
3、NESTYLE(#FF00)status=LINETO(INT2(240),INT2(50)READ(*,*)!按回车键结束程序ENDUSE MSFLIBINTEGER(2)statusINTEGER(1):style(8)/#01,#02,#04,#08,#10,#20,#40,#80/!右斜线!绘制红色空心椭圆status=SETCOLORRGB(#0000FF)status=ELLIPSE($GBORDER,80,50,240,150)!绘制白色填充斜线圆status=SETCOLORRGB(#FFFFFF)CALL SETFILLMASK(style)status=ELLIPSE($G
4、FILLINTERIOR,280,50,380,150)END例:index=SETFONT(t Times New Roman h18wl0)以像素为单位USE MSFLIBTYPE(XYCOORD)xyINTEGER(4)tcolorINTEGER(2)statusCHARACTER*8:tfont,ttype(3)*20ttype=(/隶书,楷体_GB2312,华文彩云/)tcolor=#0000FFstatus=SETTEXTCOLORRGB(#FFFFFF)status=INITIALIZEFONTS()CALL MOVETO(50,100,xy)DO i=1,3WRITE(tfon
5、t,10)i*5+20,i*3+20status=SETCOLORRGB(tcolor)status=SETFONT(t/TRIM(ttype(i)/tfont)CALL SETGTEXTROTATION(i*150)CALL OUTGTEXT(欢迎)tcolor=tcolor*#100END DO10 FORMAT(h,I2,w,I2,)ENDUSE MSFLIBINTEGER,ALLOCATABLE:score(:)INTEGER:p(5)=0CHARACTER*10 str(5)str=(/90分以上,8089分,7079分,6069分,60分以下/)OPEN(10,FILE=score
6、.dat)n=0DO WHILE(.NOT.EOF(10)READ(10,*);n=n+1END DOREWIND(10)ALLOCATE(score(n)DO i=1,nREAD(10,*)score(i)END DODO i=1,nIF(score(i)60)THENp(5)=p(5)+1ELSEIF(score(i)=100)THENp(1)=p(1)+1ELSE p(10-score(i)/10)=p(10-score(i)/10)+1ENDIFEND DOCALL PLOT_PIE(p,n,5,str)ENDSUBROUTINE PLOT_PIE(p,n,k,str)USE MSFL
7、IBINTEGER status,p(k)CHARACTER*10 str(n)REAL(8)x1,y1,x2,y2,x3,y3,x4,y4,x,yINTEGER(4):bcolor=1,tcolorPARAMETER(pi=3.141593)TYPE(WXYCOORD)tstatus=SETWINDOW(.TRUE.,-1.2,1.2,1.2,-1.2)!设置视窗大小status=SETBKCOLORRGB(#FFFFFF)CALL CLEARSCREEN($GCLEARSCREEN)status=INITIALIZEFONTS()status=SETFONT(h32p)x1=-1;y1=-
8、1x2=1;y2=1x3=1;y3=0per=0DO i=1,k!计算扇形大小per=per+2*pi*p(i)/nx4=cos(per);y4=sin(per)bcolor=bcolor*#2F status=SETCOLORRGB(bcolor)status=PIE_W($GFILLINTERIOR,x1,y1,x2,y2,x3,y3,x4,y4)x3=x4;y3=y4!显示数据标签tcolor=#1000000-bcolorstatus=SETCOLORRGB(tcolor)tper=per-pi*p(i)/n x=cos(tper)*0.7;y=sin(tper)*0.7 CALL MOVETO_W(x,y,t)CALL OUTGTEXT(str(i)END DOEND