home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 8
/
CDASC08.ISO
/
MAJ
/
2046
/
SAMPLE7.BAS
< prev
next >
Wrap
BASIC Source File
|
1993-10-07
|
6KB
|
296 lines
rem
rem This program demonstrates some simple graphics techniques
rem
rem This program runs under DOS or Windows
rem
rem
rem
rem place to store graphics figures with GET statement
rem
dim figure(100)
rem
rem go into graphics mode
rem
seterrlevel 5
err=0
screen 12
if err>0 then
err=0
screen 9
if err>0 then
err=0
screen 8
if err>0 then
err=0
screen 2
if err>0 then
print "Graphics mode not available."
end if
end if
end if
end if
seterrlevel 7
rem
rem Set some variables
rem
firstbit=1
charxsize=font(7)
charysize=font(1)
topy=system(2)
topx=system(1)
topcolor=15
rem
rem is there mouse
rem
mouseflag=mouseon
rem
REM
REM LAYOUT SCREEN
REM
CLS
line (0,0)-(topx-1,charysize*5+2),4,bf
if mouseflag<>0 then
rem
rem make my push buttons
rem
CBUTTON "Exit",1068,0,"Push",0,(1-firstbit)*charxsize,(1-firstbit)*charysize,8*charxsize,5*charysize,7,1
CBUTTON "CIRCLE",1059,0,"PUSH",0,(11-FIRSTBIT)*CHARXSIZE,(3-FIRSTBIT)*CHARYSIZE,8*CHARXSIZE,3*CHARYSIZE,7,1
CBUTTON "SQUARE",1060,0,"PUSH",0,(20-FIRSTBIT)*CHARXSIZE,(3-FIRSTBIT)*CHARYSIZE,8*CHARXSIZE,3*CHARYSIZE,7,1
CBUTTON "PIE",1061,0,"PUSH",0,(29-FIRSTBIT)*CHARXSIZE,(3-FIRSTBIT)*CHARYSIZE,8*CHARXSIZE,3*CHARYSIZE,7,1
CBUTTON "LINE",1062,0,"PUSH",0,(38-FIRSTBIT)*CHARXSIZE,(3-FIRSTBIT)*CHARYSIZE,8*CHARXSIZE,3*CHARYSIZE,7,1
CBUTTON "DOTS..",1063,0,"PUSH",0,(47-FIRSTBIT)*CHARXSIZE,(3-FIRSTBIT)*CHARYSIZE,8*CHARXSIZE,3*CHARYSIZE,7,1
CBUTTON "MOTION",1064,0,"PUSH",0,(56-FIRSTBIT)*CHARXSIZE,(3-FIRSTBIT)*CHARYSIZE,8*CHARXSIZE,3*CHARYSIZE,7,1
else
rem
rem make my push buttons when no mouse present
rem
CBUTTON "F10-Exit",1068,0,"Push",0,(1-firstbit)*charxsize,(1-firstbit)*charysize,10*charxsize,5*charysize,7,1
CBUTTON "F1-CIR.",1059,0,"PUSH",0,(12-FIRSTBIT)*CHARXSIZE,(3-FIRSTBIT)*CHARYSIZE,9*CHARXSIZE,3*CHARYSIZE,7,1
CBUTTON "F2-SQR",1060,0,"PUSH",0,(22-FIRSTBIT)*CHARXSIZE,(3-FIRSTBIT)*CHARYSIZE,8*CHARXSIZE,3*CHARYSIZE,7,1
CBUTTON "F3-PIE",1061,0,"PUSH",0,(31-FIRSTBIT)*CHARXSIZE,(3-FIRSTBIT)*CHARYSIZE,8*CHARXSIZE,3*CHARYSIZE,7,1
CBUTTON "F4-LINE",1062,0,"PUSH",0,(40-FIRSTBIT)*CHARXSIZE,(3-FIRSTBIT)*CHARYSIZE,10*CHARXSIZE,3*CHARYSIZE,7,1
CBUTTON "F5-DOTS..",1064,0,"PUSH",0,(51-FIRSTBIT)*CHARXSIZE,(3-FIRSTBIT)*CHARYSIZE,12*CHARXSIZE,3*CHARYSIZE,7,1
CBUTTON "F6-MOTION",1066,0,"PUSH",0,(64-FIRSTBIT)*CHARXSIZE,(3-FIRSTBIT)*CHARYSIZE,12*CHARXSIZE,3*CHARYSIZE,7,1
end if
rem
rem get input from keyboard
rem
100
b$ = INKEY$
IF b$ <> "" THEN
rem
rem look for function keys
rem
if len(b$)>1 then
if asc(right$(b$,1))=68 then
rem
rem F10 exit
rem
close #1
stop
elseif asc(right$(b$,1))=59 then
rem
rem circle demo
rem
gosub cleararea
x=topx/2
y=(topy+(charysize*6))/2
circle (x,y),topx/6,topcolor
gosub delay
paint (x,y),1,topcolor
elseif asc(right$(b$,1))=60 then
rem
rem square demo
rem
gosub cleararea
for i%=1 to 5
x1=int(200*rnd)
x1=x1+topx/2-100
y1=int(100*rnd)
y1=y1+(topy+(charysize*6))/2-50
x2=int(200*rnd)
x2=x2+topx/2-100
y2=int(100*rnd)
y2=y2+(topy+(charysize*6))/2-50
c=int(15*rnd)
if i%=3 or i%=5 then
line (x1,y1)-(x2,y2),c,BF
else
line (x1,y1)-(x2,y2),c,B
end if
next i%
elseif asc(right$(b$,1))=61 then
rem
rem pie demo
rem It is the CIRCLE command that supports drawing of pie shaped areas
rem
gosub cleararea
x=topx/2
y=(topy+(charysize*6))/2
circle (x,y),topx/6,topcolor,-1,-3
gosub delay
paint (x-4,y-4),1,topcolor
gosub delay
circle (x,y),topx/6,topcolor,-3,-5
gosub delay
paint (x-12,y+2),4,topcolor
gosub delay
circle (x,y),topx/6,topcolor,-5,-1
gosub delay
paint (x+12,y+5),2,topcolor
elseif asc(right$(b$,1))=62 then
rem
rem line demo
rem
gosub cleararea
for i%=1 to 300
x1=int(200*rnd)
x1=x1+topx/2-100
y1=int(100*rnd)
y1=y1+(topy+(charysize*6))/2-50
x2=int(200*rnd)
x2=x2+topx/2-100
y2=int(100*rnd)
y2=y2+(topy+(charysize*6))/2-50
c=int(15*rnd)
line (x1,y1)-(x2,y2),c
next i%
elseif asc(right$(b$,1))=63 then
rem
rem dot demo
rem
gosub cleararea
for i%=1 to 300
x=int(200*rnd)
x=x+topx/2-100
y=int(100*rnd)
y=y+(topy+(charysize*6))/2-50
c=int(15*rnd)
pset (x,y),c
next i%
elseif asc(right$(b$,1))=64 then
rem
rem motion demo
rem
gosub cleararea
x=topx/2
y=(topy+(charysize*6))/2
circle (x,y),10,topcolor
circle (x,y),4,topcolor-1
get (x-10,y-10)-(x+10,y+10),figure(0)
gosub cleararea
for ix=0 to topx step 10
line (ix,charysize*7)-(ix,topy),topcolor
next ix
oldix=9999
for ix=0 to topx-20 step 2
put (ix,y),figure(0),XOR
if oldix<9999 then
put (oldix,y),figure,XOR
end if
oldix=ix
for i=1 to 30:next i
next ix
end if
goto 100
end if
END IF
GOTO 100
rem
rem delay 1/2 second
rem
delay:
t=timer
delay5:
if timer-t<.5 then goto delay5
return
rem
rem erase display area
rem
cleararea:
by=charysize*6
line (0,by)-(topx,topy),0,bf
return