⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 svgabc25.txt

📁 Quick Basic DOS Compilers
💻 TXT
📖 第 1 页 / 共 5 页
字号:




























                                                                         20






          D2SCALE

            PROTOTYPE

            SUB D2SCALE (NumPoints%, ScaleX%, ScaleY%, InArray%,
            OutArray%)

            INPUT

            NumPoints - number of points to scale
            ScaleX - scale factor along X axis
            ScaleY - scale factor along Y axis
            InArray - P2DType array containing points to scale

            OUTPUT

            no value returned
            OutArray - P2DType array holding scaled values

            USAGE

            D2SCALE multiplies each coordinate in the two dimensional
            array InArray by the corresponding scale factor ScaleX or
            ScaleY.  The results are stored in OutArray which can be the
            same as InArray.  A scale factor of 256 (100 hex) is
            considered 100 percent and results in no change.  Therefore,
            128 (80 hex) reduces values by one half and 512 (200 hex)
            doubles values.

            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

            D2ROTATE, D2TRANSLATE

            EXAMPLE

            REM SCALE A TRIANGLE
            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


                                                                         21






            IF WHICHVGA = 0 THEN STOP
            DUMMY=RES640
            GOSUB DRWTRI
            FOR I = 256 TO 512 STEP 4
            D2SCALE 3, I, I, TRIO(1).X, TRI(1).X
            GOSUB DRWTRI
            SDELAY 2
            GOSUB ERTRI
            NEXT I
            FOR I = 512 TO 128 STEP -4
            D2SCALE 3, I, I, TRIO(1).X, TRI(1).X
            GOSUB DRWTRI
            SDELAY 2
            GOSUB ERTRI
            NEXT I

            FOR I = 128 TO 256 STEP 4
            D2SCALE 3, I, 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















                                                                         22






          D2TRANSLATE

            PROTOTYPE

            SUB D2TRANSLATE (NumPoints%, TransX%, TransY%, InArray%,
            OutArray%)

            INPUT

            NumPoints - number of points to be translated
            TransX - distance to translate along X axis
            TransY - distance to translate along Y axis
            InArray - P2DType array containing points to translate

            OUTPUT

            no value returned
            OutArray - P2DType array holding translated values

            USAGE

            D2TRANSLATE takes the two dimensional points given in InArray
            and translates them by the specified number of pixels along
            each axis.  The results are returned in OutArray which can be
            the same as InArray.

            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

            D2ROTATE, D2SCALE

            EXAMPLE

            REM TRANSLATE A TRIANGLE
            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
            GOSUB DRWTRI


                                                                         23






            FOR I = 0 TO 100 STEP 4
            D2TRANSLATE 3, I, I, TRIO(1).X, TRI(1).X
            GOSUB DRWTRI
            SDELAY 2
            GOSUB ERTRI
            NEXT I
            FOR I = 100 TO 0 STEP -4
            D2TRANSLATE 3, I, 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

























                                                                         24






          D3PROJECT

            PROTOTYPE

            FUNCTION D3PROJECT% (NumPoints%, ProjParams%, InArray%,
            OutArray%)

            INPUT

            NumPoints - number of points to be projected
            ProjParams - PROJType structure containing parameters used in
            projection
               EyeX, EyeY, EyeZ - 3D location of viewer
               ScrD - distance from viewer to projection screen
               Theta - angle from positive 3D X axis to viewing direction
               Phi - angle from positive 3D Z axis to viewing direction
            InArray - P3DType array containing points to project

            OUTPUT

            D3PROJECT returns 1 if successful, 0 if any one point failed.
            OutArray - P2DType array holding projected values

            USAGE
                                +Z axis
                                   |                   /\
                                   |                  /  \
                                   |            !     \ * \
                                   |            !......X: /
                                   |            ! Phi / \/
                                   |            !    /  :
                                   |            !   /   :
                                   |            !  /    :
                                   |       EyeX ! /ScrD :
                                   |       EyeY !/      :
                                   |       EyeZ *- - - -:- - - - -
                                   |           / `      :
                                   |          /   `     :
                                   |         /      `   :
                                   |        /      ---` :
                                   |       /___----
                                   |      /     Theta
                                   |
                                   |_____________________________+Y axis
                                   /
                                  /
                                 /
                                /
                               /
                              /
                             /
                         +X axis




                                                                         25






            D3PROJECT projects a specified number, NumPoints, of three
            dimensional points starting at InArray into two dimensions
            according to the parameters in ProjParams.  The two
            dimensional points are stored in OutArray.  The location of
            the viewer in this three dimensional space is given by EyeX,
            EyeY, EyeZ in the ProjParams structure.  The direction the
            viewer is facing is specified with ScrD, Theta, Phi in the
            ProjParams structure using spherical coordinates.  A virtual
            set of axes parallel to the true axes are placed at the
            viewer's location.  ScrD is the distance from the viewer to
            the center of the projection screen, i.e. the currently
            defined viewport on the monitor's screen.  Theta is the angle
            in the virtual X-Y plane from the virtual X axis to the
            projection screen.  Positive angles rotate counter-clockwise
            in the X-Y plane.  Lastly, the angle of elevation above or
            below the virtual X-Y plane is given by Phi.  Positive angles
            direct viewing above the plane; negative below.

            If a point is projected to a location behind the viewer, i.e.
            on the side of the viewer opposite the projection screen,
            D3PROJECT returns a zero indicating one or more failed points.
            The returned values of the X and Y for failed points will be -
            32768 to make them easily identified.

            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

            D3ROTATE, D3TRANSLATE, D3SCALE, FILLCONVEXPOLY, FILLPOLY,
            SETVIEW

            EXAMPLE

            REM DRAW A CUBE AT THE CENTER OF THE SCREEN
            REM $INCLUDE: 'SVGABC.BI'
            DEFINT A-Z
            DIM CUBE(1 TO 8) AS P3DType
            DIM PLOT(1 TO 8) AS P2DType
            DIM PROJPARAMS AS PROJType

            CUBE(1).X =  100 : CUBE(1).Y = -100 : CUBE(1).Z =  100
            CUBE(2).X =  100 : CUBE(2).Y = -100 : CUBE(2).Z = -100
            CUBE(3).X =  100 : CUBE(3).Y =  100 : CUBE(3).Z = -100
            CUBE(4).X =  100 : CUBE(4).Y =  100 : CUBE(4).Z =  100
            CUBE(5).X = -100 : CUBE(5).Y = -100 : CUBE(5).Z =  100
            CUBE(6).X = -100 : CUBE(6).Y = -100 : CUBE(6).Z = -100
            CUBE(7).X = -100 : CUBE(7).Y =  100 : CUBE(7).Z = -100
            CUBE(8).X = -100 : CUBE(8).Y =  100 : CUBE(8).Z =  100
            VMODE = VIDEOMODEGET
            IF WHICHVGA = 0 THEN STOP
            DUMMY=RES640


                                                                         26






            PROJPARAMS.EYEX = -1040
            PROJPARAMS.EYEY = -600
            PROJPARAMS.EYEZ = -1200
            PROJPARAMS.SCRD = 1700
            PROJPARAMS.THETA = 30
            PROJPARAMS.PHI = 45
            DUMMY = D3PROJECT(8,PROJPARAMS.EYEX,CUBE(1).X,PLOT(1).X)
            GOSUB DRWCUBE
            WHILE INKEY$ = ""
            WEND
            VIDEOMODESET VMODE
            END

            DRWCUBE:
            FOR J=1 TO 3
            DRWLINE 1, 10, PLOT(J).X, PLOT(J).Y, PLOT(J+1).X, PLOT(J+1).Y
            NEXT J
            DRWLINE 1, 10, PLOT(4).X, PLOT(4).Y, PLOT(1).X, PLOT(1).Y
            FOR J=5 TO 7
            DRWLINE 1, 10, PLOT(J).X, PLOT(J).Y, PLOT(J+1).X, PLOT(J+1).Y
            NEXT J
            DRWLINE 1, 10, PLOT(8).X, PLOT(8).Y, PLOT(5).X, PLOT(5).Y
            FOR J=1 TO 4
            DRWLINE 1, 10, PLOT(J).X, PLOT(J).Y, PLOT(J+4).X, PLOT(J+4).Y
            NEXT J
            RETURN




⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -