📄 svgabc25.txt
字号:
by BackFillColor. The resulting bitmap is stored in
DestGfxBlk. The size of DestGfxBlk should be at least as big
as given by BLKROTATESIZE.
The function will fail if it calculates that the internal
buffers would be overflowed or if the destination array would
be larger than 65536 bytes. BLKROTATESIZE should be called
first to ensure that buffer integrity is maintained.
SEE ALSO
BLKGET, BLKPUT, BLKRESIZE, BLKROTATESIZE
EXAMPLE
REM ROTATE A BITMAP
REM $INCLUDE: 'SVGABC.BI'
DEFINT A-Z
DIM SRC%(0 TO 32000)
DIM DST%(0 TO 32000)
IF WHICHCPU < 386 THEN END
IF WHICHVGA = 0 THEN END
VMODE = VIDEOMODEGET
IF RES640 <> 1 THEN
DUMMY = RESTEXT
END
END IF
X1 = 0
13
Y1 = 0
X2 = 110
Y2 = 110
FOR I = 0 TO 50
XA = (RND * X2 - X1) + X1
YA = (RND * Y2 - Y1) + Y1
XB = (RND * X2 - X1) + X1
YB = (RND * Y2 - Y1) + Y1
C = RND * 16
DRWLINE 1, C, XA, YA, XB, YB
NEXT I
DRWBOX 1, 15, X1, Y1, X2, Y2
BLKGET X1, Y1, X2, Y2, SRC(0)
X1 = GETMAXX \ 2
Y1 = GETMAXY \ 2
FOR I = 0 TO 359 STEP 6
IF BLKROTATESIZE(I, SRC(0)) <> 0 THEN
DUMMY = BLKROTATE(I, 0, SRC(0), DST(0))
BLKPUT 2, X1 - DST(0) \ 2, Y1 - DST(1) \ 2, DST(0)
SDELAY 3
BLKPUT 2, X1 - DST(0) \ 2, Y1 - DST(1) \ 2, DST(0)
END IF
NEXT I
VIDEOMODESET VMODE
END
14
BLKROTATESIZE
PROTOTYPE
FUNCTION BLKROTATESIZE& (Ang%, SourceGfxBlk%)
INPUT
Ang - integer degree to rotate source bitmap
SourceGfxBlk - integer source array
OUTPUT
BLKROTATESIZE returns the number of bytes needed for the
destination array if successful, 0 if unsuccessful.
USAGE
BLKROTATESIZE takes the bitmap in SourceGfxBlk calculates the
required size of the output buffer needed when BLKROTATE is
called. It also insures that the internal library buffers are
not overflowed. The function will fail if it calculates that
the internal buffers would be overflowed or if the destination
array would be larger than 65536 bytes. BLKROTATESIZE should
be called prior to BLKROTATE to ensure that buffer integrity
is maintained.
SEE ALSO
BLKGET, BLKPUT, BLKRESIZE, BLKROTATE
EXAMPLE
See BLKROTATE
15
BYTECOPY
PROTOTYPE
SUB BYTECOPY (Source AS ANY, Dest AS ANY, NumOfBytes&)
INPUT
Source - integer array to be copied
NumBytes - number of bytes to copy from Source to Dest
OUTPUT
no value returned
Dest - integer destination array holding copied data
USAGE
BYTECOPY copies the specified number of bytes from Source to
Dest. It is much faster than using a FOR/NEXT loop. NumBytes
is equal to the number of bytes to be copied. For example, if
Source contains 10 integers to be copied, NumBytes is 2 * 10,
or 20 bytes. The declaration for BYTECOPY permits any
variable type to be copied. However, BYTECOPY will not work
with strings. It will copy strings contained with a user
defined type. Remember that real numbers and long integers
are 4 bytes.
Arrays should be passed by giving the element within the array
from where the action should take place. This allows the
programmer to store more than one item within the same array
or act on only a portion of the array.
SEE ALSO
PALCOPY
EXAMPLE
REM SHOW HOW BYTE COPY WORKS ON MANY DATA TYPES
REM REMEBER: INTEGER=2 BYTES; LONG INTEGER=4 BYTES;
REM SINGLE REAL=4 BYTES; LONG REAL=8 BYTES; USER DEFINED
REM VARIABLES MUST BE CACULATED BY THEIR INDIVIDUAL PARTS;
REM $INCLUDE: 'SVGABC.BI'
TYPE MyType
CustNum AS INTEGER
CustAmnt AS SINGLE
CustName AS STRING * 20
END TYPE
DEFINT A-Z
DIM CA(0 TO 1) AS MyType
16
DIM CB(0 TO 1) AS MyType
DIM IntAryA(0 TO 2) AS INTEGER
DIM IntAryB(0 TO 2) AS INTEGER
DIM SingleAry(0 TO 5) AS SINGLE
DIM LongAryA(0 TO 2) AS LONG
DIM LongAryB(0 TO 2) AS LONG
DIM LongRealAryA(0 TO 2) AS DOUBLE
DIM LongRealAryB(0 TO 2) AS DOUBLE
FOR I = 0 TO 1
READ CA(I).CustNum
READ CA(I).CustAmnt
READ CA(I).CustName
NEXT I
FOR I = 0 TO 2
READ IntAryA(I)
NEXT I
FOR I = 0 TO 2
READ SingleAry(I)
NEXT I
FOR I = 0 TO 2
READ LongAryA(I)
NEXT I
FOR I = 0 TO 2
READ LongRealAryA(I)
NEXT I
REM HERE WE DO THE COPIES
BYTECOPY CA(0), CB(0), 48
BYTECOPY IntAryA(0), IntAryB(0), 6
BYTECOPY SingleAry(0), SingleAry(3), 12
BYTECOPY LongAryA(0), LongAryB(0), 12
BYTECOPY LongRealAryA(0), LongRealAryB(0), 24
PRINT "-------HERE ARE USER DEFINED ARRAYS:-------"
FOR I = 0 TO 1
PRINT CA(I).CustName; TAB(40); CB(I).CustName
PRINT CA(I).CustNum; TAB(40); CB(I).CustNum
PRINT CA(I).CustAmnt; TAB(40); CB(I).CustAmnt
NEXT I
PRINT "------HERE ARE SHORT INTEGER ARRAYS:-------"
FOR I = 0 TO 2
PRINT IntAryA(I); TAB(40); IntAryB(I)
NEXT I
PRINT "-------HERE ARE SHORT REAL ARRAYS:---------"
FOR I = 0 TO 2
PRINT SingleAry(I); TAB(40); SingleAry(I + 3)
NEXT I
PRINT "-------HERE ARE LONG INTEGER ARRAYS:-------"
FOR I = 0 TO 2
PRINT LongAryA(I); TAB(40); LongAryB(I)
NEXT I
PRINT "-------HERE ARE LONG REAL ARRAYS:----------"
FOR I = 0 TO 2
17
PRINT LongRealAryA(I); TAB(40); LongRealAryB(I)
NEXT I
WHILE INKEY$ = ""
WEND
REM CUSTOMER DATA
DATA 102,120.98,"John Doe"
DATA 182,160.23,"Jane Smith"
REM INTEGER DATA
DATA 2,62,9456
REM SINGLE REAL DATA
DATA 1.23,45.342,13.13
REM LONG INTEGER DATA
DATA 45000,92538,101234
REM LONG REAL DATA
DATA 345.45345,834.923734,485344.456
18
D2ROTATE
PROTOTYPE
SUB D2ROTATE (NumPoints%, XOrigin%, YOrigin%, Angle%,
InArray%, OutArray%)
INPUT
NumPoints - number of points to be rotated
Xorigin, Yorigin - center of rotation
Angle - angle of rotation about center
InArray - P2DType array containing points to rotate
OUTPUT
no value returned
OutArray - P2DType array holding rotated values
USAGE
D2ROTATE takes the two dimensional points given in InArray and
rotates them by the specified angle about Xorigin, Yorigin.
The results are returned in OutArray which can be the same as
InArray. A positive angle causes a clockwise rotation on the
screen, from the positive X axis to the positive Y axis.
Arrays should be passed by giving the element within the array
from where the action should take place. This allows the
programmer to store more than one item within the same array
or act on only a portion of the array.
SEE ALSO
D2SCALE, D2TRANSLATE
EXAMPLE
REM ROTATE A TRIANGLE ABOUT ONE CORNER
REM $INCLUDE: 'SVGABC.BI'
DEFINT A-Z
DIM TRIO(1 TO 3) AS P2DType
DIM TRI(1 TO 3) AS P2DType
DIM TRI2(1 TO 3) AS P2DType
TRIO(1).X = 0
TRIO(1).Y = 0
TRIO(2).X = -80
TRIO(2).Y = 60
TRIO(3).X = 80
TRIO(3).Y = 60
VMODE = VIDEOMODEGET
IF WHICHVGA = 0 THEN STOP
DUMMY=RES640
19
GOSUB DRWTRI
FOR I = 0 TO 360 STEP 2
D2ROTATE 3, 0, 0, I, TRIO(1).X, TRI(1).X
GOSUB DRWTRI
SDELAY 2
GOSUB ERTRI
NEXT I
GOSUB DRWTRI
WHILE INKEY$ = ""
WEND
VIDEOMODESET VMODE
END
DRWTRI:
D2TRANSLATE 3, 320, 240, TRI(1).X, TRI2(1).X
DRWLINE 1, 10, TRI2(1).X, TRI2(1).Y, TRI2(2).X, TRI2(2).Y
DRWLINE 1, 10, TRI2(2).X, TRI2(2).Y, TRI2(3).X, TRI2(3).Y
DRWLINE 1, 10, TRI2(3).X, TRI2(3).Y, TRI2(1).X, TRI2(1).Y
RETURN
ERTRI:
D2TRANSLATE 3, 320, 240, TRI(1).X, TRI2(1).X
DRWLINE 1, 0, TRI2(1).X, TRI2(1).Y, TRI2(2).X, TRI2(2).Y
DRWLINE 1, 0, TRI2(2).X, TRI2(2).Y, TRI2(3).X, TRI2(3).Y
DRWLINE 1, 0, TRI2(3).X, TRI2(3).Y, TRI2(1).X, TRI2(1).Y
RETURN
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -