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

📄 graphics.h

📁 c语言开发方面的经典问题,包括源代码.c语言开发所要注意的问题,以及在嵌入式等各方面的应用
💻 H
字号:
/* * File: graphics.h * Version: 1.0 * Last modified on Mon Jun  6 11:03:27 1994 by eroberts * ----------------------------------------------------- * This interface provides access to a simple library of * functions that make it possible to draw lines and arcs * on the screen.  This interface presents a portable * abstraction that can be used with a variety of window * systems implemented on different hardware platforms. */#ifndef _graphics_h#define _graphics_h/* * IMPORTANT NOTE FOR IBM PC USERS * ------------------------------- * Because the DOS graphics interface is also called graphics.h, * moving this file directly into the system #include path causes * a conflict.  To solve this problem, you should first rename * the system graphics file to be dosgraph.h before installing * this file.  The code below includes those definitions as part * of this interface so that existing DOS programs and the * programming examples from the text can both be compiled * without change. */#if defined( __BORLANDC__) && !defined( _Windows )#  include <dosgraph.h>#endif/* * Overview * -------- * This library provides several functions for drawing lines * and circular arcs in a region of the screen that is * defined as the "graphics window."  Once drawn, these * lines and arcs stay in their position, which means that * the package can only be used for static pictures and not * for animation. * * Individual points within the window are specified by * giving their x and y coordinates.  These coordinates are * real numbers measured in inches, with the origin in the * lower left corner, as it is in traditional mathematics. * * The calls available in the package are listed below.  More * complete descriptions are included with each function * description. * *   InitGraphics(); *   MovePen(x, y); *   DrawLine(dx, dy); *   DrawArc(r, start, sweep); *   width = GetWindowWidth(); *   height = GetWindowHeight(); *   x = GetCurrentX(); *   y = GetCurrentY(); *//* * Function: InitGraphics * Usage: InitGraphics(); * ---------------------- * This procedure creates the graphics window on the screen. * The call to InitGraphics must precede any calls to other * functions in this package and must also precede any printf * output.  In most cases, the InitGraphics call is the first * statement in the function main. */void InitGraphics(void);/* * Function: MovePen * Usage: MovePen(x, y); * --------------------- * This procedure moves the current point to the position * (x, y), without drawing a line.  The model is that of * the pen being lifted off the graphics window surface and * then moved to its new position. */void MovePen(double x, double y);/* * Function: DrawLine * Usage: DrawLine(dx, dy); * ------------------------ * This procedure draws a line extending from the current * point by moving the pen dx inches in the x direction * and dy inches in the y direction.  The final position * becomes the new current point. */void DrawLine(double dx, double dy);/* * Function: DrawArc * Usage: DrawArc(r, start, sweep); * -------------------------------- * This procedure draws a circular arc, which always begins * at the current point.  The arc itself has radius r, and * starts at the angle specified by the parameter start, * relative to the center of the circle.  This angle is * measured in degrees counterclockwise from the 3 o'clock * position along the x-axis, as in traditional mathematics. * For example, if start is 0, the arc begins at the 3 o'clock * position; if start is 90, the arc begins at the 12 o'clock * position; and so on.  The fraction of the circle drawn is * specified by the parameter sweep, which is also measured in * degrees.  If sweep is 360, DrawArc draws a complete circle; * if sweep is 90, it draws a quarter of a circle.  If the value * of sweep is positive, the arc is drawn counterclockwise from * the current point.  If sweep is negative, the arc is drawn * clockwise from the current point.  The current point at the * end of the DrawArc operation is the final position of the pen * along the arc. * * Examples: *   DrawArc(r, 0, 360)    Draws a circle to the left of the *                         current point. *   DrawArc(r, 90, 180)   Draws the left half of a semicircle *                         starting from the 12 o'clock position. *   DrawArc(r, 0, 90)     Draws a quarter circle from the 3 *                         o'clock to the 12 o'clock position. *   DrawArc(r, 0, -90)    Draws a quarter circle from the 3 *                         o'clock to the 6 o'clock position. *   DrawArc(r, -90, -90)  Draws a quarter circle from the 6 *                         o'clock to the 9 o'clock position. */void DrawArc(double r, double start, double sweep);/* * Functions: GetWindowWidth, GetWindowHeight * Usage: width = GetWindowWidth(); *        height = GetWindowHeight(); * ------------------------------------------ * These functions return the width and height of the graphics * window, in inches. */double GetWindowWidth(void);double GetWindowHeight(void);/* * Functions: GetCurrentX, GetCurrentY * Usage: x = GetCurrentX(); *        y = GetCurrentY(); * ----------------------------------- * These functions return the current x and y positions. */double GetCurrentX(void);double GetCurrentY(void);#endif

⌨️ 快捷键说明

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