📄 original_mini-x.txt
字号:
foreground and background bitmaps, and its "hot spot" position. If a pixel
is specified for both the foreground and background bitmaps, then the
foreground has precedence. The hot spot is an offset from the upper left
corner of the bitmap, and is the location in the cursor which is important.
void
GrMoveCursor(x, y)
GR_COORD x; /* new x position of cursor */
GR_COORD y; /* new y position of cursor */
Move the cursor to the specified absolute screen coordinates.
The coordinates are that of the defined hot spot of the cursor.
The cursor's appearance is changed to that defined for the window
in which the cursor is moved to.
void
GrFlush()
Flush the graphics buffer so that all previous requests will be executed.
This is only needed if you do not check events quickly and want to see the
results on the screen soon, since checking for events does an automatic flush.
void
GrSetGCForeground(gc, foreground)
GR_GC_ID gc; /* graphics context id */
GR_COLOR foreground; /* foreground color */
Set the foreground color in a graphics context. The default is white.
void
GrSetGCBackground(gc, background)
GR_GC_ID gc; /* graphics context id */
GR_COLOR background; /* background color */
Set the background color in a graphics context. The default is black.
void
GrSetGCUseBackground(gc, flag)
GR_GC_ID gc; /* graphics context id */
GR_BOOL flag; /* TRUE if background is drawn */
Set whether or not the background color is drawn in bitmaps and text.
This affects GrBitmap, GrArea8, and GrText. The default is GR_TRUE.
void
GrSetGCMode(gc, mode)
GR_GC_ID gc; /* graphics context id */
GR_MODE mode; /* drawing mode */
Set the drawing mode in a graphics context. The drawing mode is one of
GR_MODE_SET, GR_MODE_XOR, GR_MODE_AND, or GR_MODE_OR. The default is
GR_MODE_SET.
void
GrSetGCFont(gc, font)
GR_GC_ID gc; /* graphics context id */
GR_FONT font; /* text font */
Set the font used for text drawing in a graphics context.
The font is a number identifying one of several fonts.
Font number 0 is always available, and is the default font.
void
GrLine(id, gc, x1, y1, x2, y2)
GR_DRAW_ID id;
GR_GC_ID gc;
GR_COORD x1;
GR_COORD y1;
GR_COORD x2;
GR_COORD y2;
Draw a line in the specified drawable using the specified graphics context.
void
GrRect(id, gc, x, y, width, height)
GR_DRAW_ID id;
GR_GC_ID gc;
GR_COORD x;
GR_COORD y;
GR_SIZE width;
GR_SIZE height;
Draw the boundary of a rectangle in the specified drawable using the
specified graphics context.
void
GrFillRect(id, gc, x, y, width, height)
GR_DRAW_ID id;
GR_GC_ID gc;
GR_COORD x;
GR_COORD y;
GR_SIZE width;
GR_SIZE height;
Fill a rectangle in the specified drawable using the specified graphics
context. The boundary of this rectangle is identical to that drawn by
the GrRect function.
void
GrEllipse(id, gc, x, y, rx, ry)
GR_DRAW_ID id;
GR_GC_ID gc;
GR_COORD x;
GR_COORD y;
GR_SIZE rx;
GR_SIZE ry;
Draw the boundary of an ellipse in the specified drawable with
the specified graphics context.
void
GrFillEllipse(id, gc, x, y, rx, ry)
GR_DRAW_ID id;
GR_GC_ID gc;
GR_COORD x;
GR_COORD y;
GR_SIZE rx;
GR_SIZE ry;
Fill an ellipse in the specified drawable using the specified
graphics context.
void
GrBitmap(id, gc, x, y, width, height, bitmaptable)
GR_DRAW_ID id;
GR_GC_ID gc;
GR_COORD x;
GR_COORD y;
GR_SIZE width;
GR_SIZE height;
GR_BITMAP *bitmaptable;
Draw a rectangular area in the specified drawable using the specified
graphics context, as determined by the specified bit map. This differs
from rectangle drawing in that the rectangle is drawn using the foreground
color and possibly the background color as determined by the bit map.
Bits which are 1 are the foreground, and bits which are 0 are the background.
Each row of bits is aligned to the next bitmap word boundary (so there can
be padding at the end of each row). The background bit values are only
written if the usebackground flag is set in the GC.
void
GrArea8(id, gc, x, y, width, height, colortable)
GR_DRAW_ID id;
GR_GC_ID gc;
GR_COORD x;
GR_COORD y;
GR_SIZE width;
GR_SIZE height;
GR_COLOR8 *colortable;
Draw a rectangular area in the specified drawable using the specified
graphics context. This differs from rectangle drawing in that the
color values for each pixel in the rectangle are specified. The color
values are estricted to 8 bit values. The color table is indexed row by
row from left to right. Table values whose color matches the background
color are only written if the usebackground flag is set in the GC.
void
GrReadArea8(id, x, y, width, height, colortable)
GR_DRAW_ID id;
GR_COORD x;
GR_COORD y;
GR_SIZE width;
GR_SIZE height;
GR_COLOR8 *colortable;
Read the color values from the specified rectangular area of the specified
drawable into a supplied buffer. If the drawable is a window which is
obscured by other windows, then the returned values will include the values
from the covering windows. Regions outside of the screen boundaries, or
from unmapped windows will return black.
void
GrPoint(id, gc, x, y)
GR_DRAW_ID id;
GR_GC_ID gc;
GR_COORD x;
GR_COORD y;
Draw a point in the specified drawable using the specified graphics context.
void
GrPoly(id, gc, count, pointtable)
GR_DRAW_ID id;
GR_GC_ID gc;
GR_COUNT count;
GR_POINT *pointtable;
Draw a polygon in the specified drawable using the specified graphics
context. The polygon is only complete if the first point is repeated at
the end. Note: currently if the polygon crosses itself, and the drawing
mode is set to XOR, then the individual line segments will affect each
other. The endpoints of the lines are correct, however.
void
GrFillPoly(id, gc, count, pointtable)
GR_DRAW_ID id;
GR_GC_ID gc;
GR_COUNT count;
GR_POINT *pointtable;
Draw a filled polygon in the specified drawable using the specified
graphics context. The last point may be a duplicate of the first point,
but this is not required. Note: currently only convex polygons are
filled properly.
void
GrText(id, gc, x, y, str, count)
GR_DRAW_ID id;
GR_GC_ID gc;
GR_COORD x;
GR_COORD y;
GR_CHAR *str;
GR_COUNT count;
Draw a text string at the specified location in the specified drawable
using the specified graphics context. The background of the characters
are only drawn if the usebackground flag in the GC is set.
EXAMPLE PROGRAM
The following simple program opens the graphics, creates a window, prints
some text in it, waits for the mouse to be clicked in the window, then exits.
#include <stdio.h>
#include <graphics.h>
#define MARGIN 50 /* margin around window */
main()
{
GR_WINDOW_ID wid; /* window id */
GR_GC_ID gc; /* graphics context id */
GR_EVENT event; /* current event */
GR_SCREEN_INFO si; /* screen information */
if (GrOpen() < 0) {
fprintf(stderr, "Cannot open graphics\n");
exit(1);
}
GrGetScreenInfo(&si);
wid = GrNewWindow(GR_ROOT_WINDOW_ID, MARGIN, MARGIN,
si.cols - MARGIN * 2, si.rows - MARGIN * 2,
1, si.black, si.white);
GrSelectEvents(wid, GR_EVENT_MASK_BUTTON_DOWN | GR_EVENT_MASK_EXPOSURE);
GrMapWindow(wid);
gc = GrNewGC();
while (1) {
GrGetNextEvent(&event);
switch (event.type) {
case GR_EVENT_TYPE_BUTTON_DOWN:
if (event.button.wid != wid)
break;
GrClose();
exit(0);
case GR_EVENT_TYPE_EXPOSURE:
if (event.exposure.wid == wid)
GrText(wid, gc, 50, 50, "EXIT", 4);
break;
}
}
}
For a more complete demonstration program, see the file "demo.c" in the
/usr/src/graphics/clients directory.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -