BGI.PRG
上传用户:abc1382430
上传日期:2013-01-31
资源大小:1233k
文件大小:4k
- *********************************************************
- *
- * Name: Bgi
- * 此程序演示基本图形函数
- *
- *********************************************************
- set talk off
- set curs off
- set path to ..
- do LoadSDK
- priv all like P_*
- P_Color='B/W,W+/B,W/W,W+/B,W/B,W+/B,GR/W,W/B,N/W,W+/W'
- =DefiWind("Demo",1,2,srows()-2,scols()-3,"colo &P_Color titl '图形函数演示'")
- =ActiWind("Demo")
- Demo_X1=C2X(1)
- Demo_Y1=R2Y(1)
- Demo_X2=C2X(wcol("Demo")-1)
- Demo_Y2=R2Y(wrow("Demo"))
- Demo_X=(Demo_X2-Demo_X1)/2+Demo_X1
- Demo_Y=(Demo_Y2-Demo_Y1)/2+Demo_Y1
- =DnRect(Demo_X1-1,Demo_Y1-1,Demo_X2+1,Demo_Y2+1)
- do PixelDemo
- if last()#27
- do LineDemo
- endi
- if last()#27
- do RectDemo
- endi
- if last()#27
- do BarDemo
- endi
- if last()#27
- do ElpDemo
- endi
- if last()#27
- do SectorDemo
- endi
- =ReleWind('Demo')
- retu
- func RandNum
- para LowLimit,HighLimit
- retu LowLimit+rand()*(HighLimit-LowLimit)
- *----------------------------------------------------------------------
- func PixelDemo
- =SetFillStyle(1,0)
- =DrawBar(Demo_X1,Demo_Y1,Demo_X2,Demo_Y2)
- for P_Counter=1 to 3000
- P_X1=int(RandNum(Demo_X1,Demo_X2))
- P_Y1=int(RandNum(Demo_Y1,Demo_Y2))
- P_Color=int(RandNum(0,255))
- =PutPixel(P_X1,P_Y1,P_Color)
- if chrs()
- exit
- endi
- endf
- =inke()
- retu
- *----------------------------------------------------------------------------
- proc LineDemo
- priv all like P_*
- =SetFillStyle(1,0)
- =DrawBar(Demo_X1,Demo_Y1,Demo_X2,Demo_Y2)
- for P_Counter=1 to 2000
- P_X1=int(RandNum(Demo_X1,Demo_X2))
- P_Y1=int(RandNum(Demo_Y1,Demo_Y2))
- P_X2=Demo_X+(Demo_X-P_X1)
- P_Y2=Demo_Y+(Demo_Y-P_Y1)
- P_Color=int(rand()*255)
- =SetColor(P_Color)
- =DrawLine(P_X1,P_Y1,P_X2,P_Y2)
- if chrs()
- exit
- endi
- endf
- if inke()=27
- retu
- endi
- =inke()
- retu
- *------------------------------------------------------------------------
- func RectDemo
- priv all like P_*
- =SetFillStyle(1,0)
- =DrawBar(Demo_X1,Demo_Y1,Demo_X2,Demo_Y2)
- for P_Counter=1 to 1000
- P_X1=int(RandNum(Demo_X1,Demo_X2))
- P_Y1=int(RandNum(Demo_Y1,Demo_Y2))
- P_X2=Demo_X+(Demo_X-P_X1)
- P_Y2=Demo_Y+(Demo_Y-P_Y1)
- * P_X2=int(RandNum(Demo_X1,Demo_X2))
- * P_Y2=int(RandNum(Demo_Y1,Demo_Y2))
- P_Color=int(rand()*255)
- =SetColor(P_Color)
- =Rect(P_X1,P_Y1,P_X2,P_Y2)
- if chrs()
- exit
- endi
- endf
- =inke()
- retu
- *------------------------------------------------------------------------
- func BarDemo
- priv all like P_*
- =SetFillStyle(1,0)
- =DrawBar(Demo_X1,Demo_Y1,Demo_X2,Demo_Y2)
- for P_Counter=1 to 500
- P_X1=int(RandNum(Demo_X1,Demo_X2))
- P_Y1=int(RandNum(Demo_Y1,Demo_Y2))
- P_X2=int(RandNum(Demo_X1,Demo_X2))
- P_Y2=int(RandNum(Demo_Y1,Demo_Y2))
- P_Color=int(rand()*255)
- P_Style=int(rand()*11)
- =SetFillStyle(P_Style,P_Color)
- =DrawBar(P_X1,P_Y1,P_X2,P_Y2)
- =SetColor(P_Color)
- =Rect(P_X1,P_Y1,P_X2,P_Y2)
- if chrs()
- exit
- endi
- endf
- =inke()
- =SetFillStyle(1,0)
- retu
- *------------------------------------------------------------------------
- func ElpDemo
- priv all like P_*
- =SetFillStyle(1,0)
- =DrawBar(Demo_X1,Demo_Y1,Demo_X2,Demo_Y2)
- for P_Counter=1 to 500
- P_X=int(RandNum(Demo_X1+10,Demo_X2-10))
- P_Y=int(RandNum(Demo_Y1+10,Demo_Y2-10))
- P_RX=min(Demo_X2-P_X,P_X-Demo_X1)/2-5
- P_RY=min(Demo_Y2-P_Y,P_Y-Demo_Y1)/2-5
- P_RX=int(RandNum(0,P_RX))+10
- P_RY=int(RandNum(0,P_RY))+10
- P_RX=iif(P_RX<10,10,P_RX)
- P_RY=iif(P_RY<10,10,P_RY)
- P_Color=int(rand()*255)
- =SetColor(P_Color)
- =Ellipse(P_X,P_Y,0,360,P_RX,P_RY)
- if chrs()
- exit
- endi
- endf
- =inke()
- retu
- *------------------------------------------------------------------------
- func SectorDemo
- priv all like P_*
- =SetFillStyle(1,0)
- =DrawBar(Demo_X1,Demo_Y1,Demo_X2,Demo_Y2)
- for P_Counter=1 to 500
- P_X=int(RandNum(Demo_X1+10,Demo_X2-10))
- P_Y=int(RandNum(Demo_Y1+10,Demo_Y2-10))
- P_RX=min(Demo_X2-P_X,P_X-Demo_X1)/2-5
- P_RY=min(Demo_Y2-P_Y,P_Y-Demo_Y1)/2-5
- P_RX=int(RandNum(0,P_RX))+10
- P_RY=int(RandNum(0,P_RY))+10
- P_RX=iif(P_RX<10,10,P_RX)
- P_RY=iif(P_RY<10,10,P_RY)
- P_A1=int(rand()*360)
- P_A2=int(rand()*360)
-
- P_Color=int(rand()*255)
- =SetColor(P_Color)
- =Sector(P_X,P_Y,P_A1,P_A2,P_RX,P_RY)
- if chrs()
- exit
- endi
- endf
- =inke()
- retu