/*
* File: graphics.c
* Version: 3.1
* Last modified on Thu Feb 23 13:39:32 1995 by eroberts
* -----------------------------------------------------
* This file implements the graphics.h and extgraph.h interfaces
* for the Borland/Windows platform.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <conio.h>
#include <windows.h>
#include <time.h>
#include <wincon.h>
#include <Windows.h>
#include "genlib.h"
#include "gcalloc.h"
#include "strlib.h"
#include "extgraph.h"
/*
* Parameters
* ----------
* DesiredWidth -- Desired width of the graphics window
* DesiredHeight -- Desired height of the graphics window
* DefaultSize -- Default point size
* MaxTitle -- Maximum window title length
* MaxFontName -- Maximum font name length
* MaxFonts -- Maximum number of fonts
* LeftMargin -- Margin from left of screen to both windows
* RightMargin -- Minimum margin to right of windows
* TopMargin -- Margin from top of screen to graphics window
* BottomMargin -- Minimum margin from bottom of screen to console window
* WindowSep -- Separation between graphics and console windows
* ConsoleHeight -- Height of the console window (pixels)
* MinConsoleScale -- Smallest acceptable scale factor for the console
* PStartSize -- Starting size for polygon (must be greater than 1)
* MaxColors -- Maximum number of color names allowed
* MinColors -- Minimum number of colors the device must support
* GWClassName -- Class name of the graphics window
* DefaultFont -- Font that serves as the "Default" font
*/
#define DesiredWidth 10.0
#define DesiredHeight 7.0
#define DefaultSize 12
#define MaxTitle 75
#define MaxFontName 50
#define MaxFonts 100
#define LeftMargin 0/*10*/
#define RightMargin 25
#define TopMargin 0
#define BottomMargin 30
#define WindowSep 5
#define ConsoleHeight 110
#define MinConsoleScale 0.8
#define PStartSize 50
#define MaxColors 256
#define MinColors 16
#define GWClassName "Graphics Window"
#define DefaultFont "System"
/*
* Other constants
* ---------------
* LargeInt -- Integer too large for a coordinate value
* Epsilon -- Small arithmetic offset to reduce aliasing/banding
* Pi -- Mathematical constant pi
* AnyButton -- Union of all mouse buttons
*/
#define LargeInt 16000
#define Epsilon 0.00000000001
#define Pi 3.1415926535
#define AnyButton (MK_LBUTTON | MK_RBUTTON | MK_MBUTTON)
KeyboardEventCallback g_keyboard = NULL;
MouseEventCallback g_mouse = NULL;
TimerEventCallback g_timer = NULL;
CharEventCallback g_char = NULL;
/*
* Type: graphicsStateT
* --------------------
* This structure holds the variables that make up the graphics state.
*/
typedef struct graphicsStateT {
double cx, cy;
string font;
int size;
int style;
bool erase;
int color;
struct graphicsStateT *link;
} *graphicsStateT;
/*
* Type: fontEntryT
* ----------------
* This structure holds the data for a font.
*/
typedef struct {
string name;
int size, style;
int points, ascent, descent, height;
HFONT font;
} fontEntryT;
/*
* Type: regionStateT
* ------------------
* The region assembly process has the character of a finite state
* machine with the following four states:
*
* NoRegion Region has not yet been started
* RegionStarting Region is started but no line segments yet
* RegionActive First line segment appears
* PenHasMoved Pen has moved during definition
*
* The current state determines whether other operations are legal
* at that point.
*/
typedef enum {
NoRegion, RegionStarting, RegionActive, PenHasMoved
} regionStateT;
/*
* Type: colorEntryT
* -----------------
* This type is used for the entries in the color table.
*/
typedef struct {
string name;
double red, green, blue;
} colorEntryT;
/*
* Static table: fillList
* ----------------------
* This table contains the bitmap patterns for the various density
* values. Adding more patterns to this list increases the
* precision with which the client can control fill patterns.
* Note that this bitmap is inverted from that used on most
* systems, with 0 indicating foreground and 1 indicating background.
*/
static short fillList[][8] = {
{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
{ 0x77, 0xDD, 0x77, 0xDD, 0x77, 0xDD, 0x77, 0xDD },
{ 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA },
{ 0x88, 0x22, 0x88, 0x22, 0x88, 0x22, 0x88, 0x22 },
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
};
#define NFills (sizeof fillList / sizeof fillList[0])
/*
* Global variables
* ----------------
* initialized -- TRUE if initialization has been done
* pauseOnExit -- TRUE if library should pause when exiting
* consoleWindow -- Window handle for console window
* graphicsWindow -- Window handoe for graphics window
* gdc -- Graphics DC (screen)
* osdc -- Offscreen DC (memory backup)
* osbits -- Offscreen bitmap
* drawPen -- Pen used for drawing
* erasePen -- Pen used for erasing
* nullPen -- Pen used for filling
* drawColor -- Color used for drawing
* eraseColor -- Color used for erasing
* windowTitle -- Current window title (initialized statically)
* xResolution -- Horizontal resolution of screen (dots per inch)
* yResolution -- Vertical resolution of screen (dots per inch)
* windowWidth -- Width of graphics window (inches)
* windowHeight -- Height of graphics window (inches)
* pixelWidth -- Width of graphics window (pixels)
* pixelHeight -- Height of graphics window (pixels)
* fontTable -- Table of stored fonts
* nFonts -- Number of fonts in fontTable
* currentFont -- Index of current font in fontTable
* regionState -- Current state of the region
* regionDensity -- Fill density to apply to region
* polygonPoints -- Array of points used in current region
* nPolygonPoints -- Number of active points
* polygonSize -- Number of allocated points
* polygonBounds -- Bounding box of polygon
* colorTable -- Table of defined colors
* nColors -- Number of defined colors
* previousColor -- Last color index set
* stateStack -- Stack of graphicStateT blocks
* cx, cy -- Current coordinates | These
* eraseMode -- Setting of erase flag | variables
* textFont -- Current font | consititute
* textStyle -- Current style | the current
* pointSize -- Current point size | graphics
* penColor -- Color of pen | state
*/
static int penSize = 1;
static bool initialized = FALSE;
static bool pauseOnExit = TRUE;
static HWND consoleWindow, graphicsWindow;
static HDC gdc, osdc;
static HBITMAP osBits;
static HPEN drawPen, erasePen, nullPen;
static COLORREF drawColor, eraseColor;
static PAINTSTRUCT ps;
static string windowTitle = "Graphics Window";
static double xResolution, yResolution;
static double windowWidth = DesiredWidth;
static double windowHeight = DesiredHeight;
static int pixelWidth, pixelHeight;
static fontEntryT fontTable[MaxFonts];
static int nFonts;
static int currentFont;
static regionStateT regionState;
static double regionDensity;
static POINT *polygonPoints;
static int nPolygonPoints;
static int polygonSize;
static RECT polygonBounds;
static HBITMAP fillBitmaps[NFills];
static colorEntryT colorTable[MaxColors];
static int nColors;
static int previousColor;
static graphicsStateT stateStack;
static double cx, cy;
static bool eraseMode;
static string
没有合适的资源?快使用搜索试试~ 我知道了~
igp.rar_rangepev_交互
共43个文件
c:16个
o:15个
h:8个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 147 浏览量
2022-09-21
01:28:43
上传
评论
收藏 102KB RAR 举报
温馨提示
画图程序,可以实现对屏幕中圆的:改变大小、改变位置、设置半径大小,也支持输入字符串以及闪烁
资源推荐
资源详情
资源评论
收起资源包目录
igp.rar (43个子文件)
igp
igp_timer.c 2KB
Makefile.win 2KB
igp_keyboard.o 6KB
igp_keyboard2.o 2KB
igp_mouse.o 4KB
igp_char.o 2KB
graphics.dev 3KB
igp.o 11KB
igp_timer.o 2KB
igp1.c 10KB
include
simpio.h 2KB
random.h 2KB
strlib.h 7KB
gcalloc.h 2KB
graphics.h 6KB
extgraph.h 15KB
exception.h 8KB
genlib.h 6KB
igp_keyboard.c 4KB
igp11.c 827B
igp1.o 12KB
graphics.layout 1KB
igp.c 9KB
fun.c 2KB
graphics.exe 80KB
igp11.o 2KB
libgraphics
graphics.c 54KB
graphics.o 34KB
exceptio.c 3KB
strlib.c 5KB
simpio.o 2KB
strlib.o 5KB
exceptio.o 1KB
random.o 1KB
genlib.o 2KB
simpio.c 4KB
genlib.c 4KB
random.c 2KB
igp_char.c 2KB
fun.o 4KB
igp2.c 9KB
igp_keyboard2.c 894B
igp_mouse.c 3KB
共 43 条
- 1
资源评论
Kinonoyomeo
- 粉丝: 77
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功