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

📄 fgkslib.old

📁 开放源码的编译器open watcom 1.6.0版的源代码
💻 OLD
📖 第 1 页 / 共 3 页
字号:
.us Set Colour Representation
subroutine to define the precise amount of red, green and blue
primaries for a specific colour index.
.code
GSCR( WK_ID, COLOUR_INDEX, RED_AMOUNT, GREEN_AMOUNT, BLUE_AMOUNT )
.ecode
.pc
WK_ID is defined by the "GKSDEFN.FOR" include file.
RED_AMOUNT, GREEN_AMOUNT and BLUE_AMOUNT are REAL values in the
range 0.0 to 1.0.
.*
:H3.ELLIPSE Subroutine
.*
:I1.ELLIPSE subroutine
.cbox
    SUBROUTINE ELLIPSE( X, Y, X_AXIS, Y_AXIS, COLOUR_INDEX )
    REAL X, Y, X_AXIS, Y_AXIS
    INTEGER COLOUR_INDEX
.ecbox
.np
This subroutine draws an ellipse with centre at coordinates (X,Y)
using the specified colour index.
X_AXIS is the distance from the edge of the ellipse to the centre
along the horizontal axis and Y_AXIS is the distance along the
vertical axis.
.*
:H3.ELL_ARC Subroutine
.*
:I1.ELL_ARC subroutine
.cbox
    SUBROUTINE ELL_ARC( X, Y, X_AXIS, Y_AXIS, COLOUR_INDEX,
   1                 START, FINISH )
    REAL X, Y, X_AXIS, Y_AXIS
    INTEGER COLOUR_INDEX, START, FINISH
.ecbox
.np
This subroutine draws an elliptical arc with centre at coordinates
(X,Y) using the specified colour index.
X_AXIS is the distance from the edge of the ellipse to the centre
along the horizontal axis and Y_AXIS is the distance along the
vertical axis.
The start and finish angles of the arc are expressed in degrees
between 0 and 360.
A start angle of 0 represents the point (X+X_AXIS,Y).
The arc is drawn in the counter-clockwise direction.
.*
:H3.FINISH Subroutine
.*
:I1.FINISH subroutine
.cbox
    SUBROUTINE FINISH
.ecbox
.np
This subroutine closes the graphics system.
This routine should be called when a program is finished generating
graphics.
The routine waits for the user to press the "Enter" key before
resetting the screen.
.*
:H3.GETPIC Subroutine
.*
:I1.GETPIC subroutine
.cbox
    SUBROUTINE GETPIC( X1, Y1, X2, Y2, PIC )
    REAL X1, Y1, X2, Y2
    CHARACTER*80 PIC(1:PIC_SIZE)
.ecbox
.np
An image on the screen is stored in the CHARACTER array PIC.
The coordinates (X1,Y1) and (X2,Y2) define the opposite corners of a
rectangle which surrounds the object.
The colour indices corresponding to each point within this rectangle
are stored in the CHARACTER array PIC.
The size of the array required is determined by the size of the
rectangle and the number of bits per dot required by the current mode
setting.
The graphics library declares that the arrays have a maximum size
specified by the constant PIC_SIZE.
If an error is diagnosed that the array is not sufficiently large, the
constant PIC_SIZE can be adjusted.
.*
:H3.INIT Subroutine
.*
:I1.INIT subroutine
.cbox
    SUBROUTINE INIT( CHOICE )
    INTEGER CHOICE
.ecbox
.np
This subroutine initializes the graphics system to the requested mode.
CHOICE is one of the 16 available selections described in
:FIGREF refid='gref1' page=yes.
or it may be 0, in which case an attempt is made to determine which
type of adapter is present in the computer.
This routine must be called before any graphics images can be drawn.
.*
:H3.LINE Subroutine
.*
:I1.LINE subroutine
.cbox
    SUBROUTINE LINE( X1, Y1, X2, Y2, COLOUR_INDEX )
    REAL X1, Y1, X2, Y2
    INTEGER COLOUR_INDEX
.ecbox
.np
This subroutine draws a line from the point with coordinates (X1,Y1)
to the point with coordinates (X2,Y2) using the specified colour
index.
.*
:H3.PAINT Subroutine
.*
:I1.PAINT subroutine
.cbox
    SUBROUTINE PAINT( X, Y, COLOUR_INDEX )
    REAL X, Y
    INTEGER COLOUR_INDEX
.ecbox
.np
This subroutine solidly fills an area of the screen using the
specified colour index.
Starting at the point (X,Y), surrounding points are coloured within an
area bounded by the edges of the screen or a figure of colour
different than the original colour of point (X,Y).
.*
:H3.PAINT_BOUNDARY Subroutine
.*
:I1.PAINT_BOUNDARY subroutine
.cbox
    SUBROUTINE PAINT_BOUNDARY( X, Y, COLOUR_INDEX, BOUNDARY )
    REAL X, Y
    INTEGER COLOUR_INDEX, BOUNDARY
.ecbox
.np
This subroutine solidly fills an area of the screen using the
specified colour index.
Starting at the point (X,Y), surrounding points are coloured within an
area bounded by the edges of the screen or a figure of the colour
index specified by BOUNDARY.
.*
:H3.PUTDOT Subroutine
.*
:I1.PUTDOT subroutine
.cbox
    SUBROUTINE PUTDOT( X, Y, COLOUR_INDEX )
    REAL X, Y
    INTEGER COLOUR_INDEX
.ecbox
.np
This subroutine places a dot using the specified colour index at the
point with coordinates (X,Y).
.*
:H3.PUTPIC Subroutine
.*
:I1.PUTPIC subroutine
.cbox
    SUBROUTINE PUTPIC( X, Y, PIC )
    REAL X, Y
    CHARACTER*80 PIC(1:PIC_SIZE)
.ecbox
.np
This subroutine displays the graphic image previously stored in the
CHARACTER array PIC with routine GETPIC.
The picture is positioned with coordinates (X,Y) designating the top
left corner of the rectangle.
.*
:H3.PUTPIC_ACTION Subroutine
.*
:I1.PUTPIC_ACTION subroutine
.cbox
    SUBROUTINE PUTPIC_ACTION( X, Y, PIC, ACTION )
    REAL X, Y
    CHARACTER*80 PIC(1:PIC_SIZE)
    INTEGER ACTION
.ecbox
.np
This subroutine displays the graphic image previously stored in the
CHARACTER array PIC with routine GETPIC.
The picture is positioned with coordinates (X,Y) designating the top
left corner of the rectangle.
The INTEGER argument ACTION is a numeric value representing how the
new picture blends with what is currently in the rectangular area of
the screen.
.begpoint
:DTHD.Actions::DDHD.~b
.point 0
Replace the current picture.
This is equivalent to PUTPIC.
.point 1
The resulting picture corresponds to the exclusive-or (XOR) of the
current and stored picture.
The effect of "exclusive-oring" two images involves the bit-wise XOR
of the binary representation of the colour indices for corresponding
pixels.
For example, if the colour index for a pixel on the screen is 2 and
the corresponding colour index in PIC is 0 then the resulting colour
index will be 1 (in binary, 10 XOR 00 = 01).
.np
If PIC is again XOR'ed with the new image on the screen, the resulting
colour index will be 2 (in binary, 01 XOR 00 = 10).
This is the original colour index.
Thus, an image can be superimposed on an existing picture with one XOR
invocation of PUTPIC_ACTION, and the existing picture restored with a
second identical invocation of PUTPIC_ACTION.
This is useful for animation.
.point 2
The resulting picture corresponds to the logical AND of the current
and stored picture.
The effect of "anding" two images involves the bit-wise AND of the
binary representation of the colour indices for corresponding pixels.
For example, if the colour index for a pixel on the screen is 1 and
the corresponding colour index in PIC is 2 then the resulting colour
index will be 0 (in binary, 01 & 10 = 00).
.point 3
The resulting picture corresponds to the logical OR of the current and
stored picture.
This operation involves the bit-wise OR of the binary representation
of the colour indices for corresponding pixels.
For example, if the colour index for a pixel on the screen is 1 and
the corresponding colour index in PIC is 2 then the resulting colour
index will be 3 (in binary, 01 | 10 = 11).
.endpoint
.*
:H3.SLICE Subroutine
.*
:I1.SLICE subroutine
.cbox
    SUBROUTINE SLICE( X, Y, RADIUS, COLOUR_INDEX, START, FINISH )
    REAL X, Y, RADIUS, ANGLE
    INTEGER COLOUR_INDEX, START, FINISH
.ecbox
.np
This subroutine draws a wedge of a pie chart with centre at the
coordinates (X,Y) using the specified colour index.
This routine is similar to CIRC_ARC, except that the ends of the arc
are joined to the centre point and the interior is filled with the
specified colour.
.*
:H3.TEXT Subroutine
.*
:I1.TEXT subroutine
.cbox
    SUBROUTINE TEXT( X, Y, STR, COLOUR_INDEX )
    REAL X, Y
    CHARACTER*(*) STR
    INTEGER COLOUR_INDEX
.ecbox
.np
This subroutine displays the CHARACTER variable STR at the point with
coordinates (X,Y) using the specified colour index.
.*
:H2.GKS Cover Functions
.*
:I1.GKS cover functions
.*
:H3.GETDOT Function
.*
:I1.GETDOT function
.cbox
    INTEGER FUNCTION GETDOT( X, Y )
    REAL X, Y
.ecbox
.np
This INTEGER function returns a numeric value representing the colour
index of the point specified by coordinates (X,Y).
.*
:H2.Example Programs
.*
The GKS cover subprograms are accompanied by a number of example
programs illustrating how to use the routines in the library.
The example programs are:
.begnote
.note BLOCK.FOR
:I1.BLOCK.FOR
illustrates the BLOCK subroutine by drawing several solidly coloured
blocks on the screen.
.note BOX.FOR
:I1.BOX.FOR
illustrates the BOX subroutine by drawing several boxes in different
colours.
.note CIRCARC.FOR
:I1.CIRCARC.FOR
is similar to the circle example program, except that only partial
circles are drawn.
.note CIRCLE.FOR
:I1.CIRCLE.FOR
illustrates the CIRCLE subroutine by drawing circles with different
radii.
.note COLOURMA.FOR
:I1.COLOURMA.FOR
illustrates the COLOURMAP subroutine by redefining the colours
associated with colour indices 0, 1, 2 and 3.
This program only works on adapters that support colour mapping such
as the IBM PCjr, the EGA, the VGA and the MCGA.
.note DOG.FOR
:I1.DOG.FOR
is a larger program using many of the graphics routines to create an
animated cartoon.
.note ELLARC.FOR
:I1.ELLARC.FOR
is similar to the ellipse example program, except that only partial
ellipses are drawn.
.note ELLIPSE.FOR
:I1.ELLIPSE.FOR
is similar to the circle example program except that ellipses are
drawn instead of circles.
.note LINE.FOR
:I1.LINE.FOR
illustrates the LINE subroutine by drawing several lines in different
colours.
.note PAINT.FOR
:I1.PAINT.FOR
illustrates and describes the differences between the PAINT and
PAINT_BOUNDARY subroutines by filling the interior of two boxes.
.note PICTURE.FOR
:I1.PICTURE.FOR
illustrates the GETPIC and PUTPIC subroutines.
.note SLICE.FOR
:I1.SLICE.FOR
illustrates the SLICE subroutine by drawing a pie chart.
.note TEXT.FOR
:I1.TEXT.FOR
illustrates the TEXT subroutine by drawing several text strings
positioned around the screen.
.endnote
.*
:H2.Running the Example Programs
.*
In the following examples, we assume that "&pathnamup" is the
directory in which the &product and WATCOM GKS software was installed.
To run the example programs, you must first compile and link them.
We will compile and link the "BLOCK" demonstration program as an example.
.code
C>set lib=&pathnam&libdir\dos
C>set finclude=&pathnam\src\fortran\gkscover
C>&wclcmd &pathnam\src\fortran\gksdemos\block wgkscvr.lib wgks.lib
.ecode
.np
Then you must load WATCOM GKS into memory by issuing a command similar
to the following:
.millust
C>wgks
.emillust
.np
If you have a Hercules Graphics Adapter, you should also run the
"HERCBIOS.COM" program as follows:
.millust
C>hercbios
.emillust
.np
To run the "BLOCK" demonstration program, enter its name:
.millust
C>block
.emillust
.pc
After the program has completed, press the "Enter" key to return to
the DOS prompt.
At this point, changes can be made to the demonstration program and
the program can be compiled, linked, and run again.
Continue in the same manner to compile, link, and run all of the
example programs.
.np
When no more GKS applications will be run, the "HERCBIOS" program can
be removed from memory (if previously installed) by entering the
following command.
.millust
C>hercbios quit
.emillust
.pc
The "quit" option directs "HERCBIOS" to remove itself from memory.
.np
The WATCOM GKS memory-resident task may be removed from memory by
entering the following command.
:I1.GKS:I2.stopping
.millust
C>wgks quit
.emillust
.pc
The "quit" option directs WATCOM GKS to remove itself from memory.
.remark
If you load WGKS first and HERCBIOS second, you must unload them in the
opposite order (i.e., HERCBIOS then WGKS).
.eremark

⌨️ 快捷键说明

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