/*
GRAPHICS DEMO FOR TURBO C 2.0
Copyright (c) 1987,88 Borland International. All rights reserved.
From the command line, use:
tcc bgidemo graphics.lib
*/
#ifdef __TINY__
#error BGIDEMO will not run in the tiny model.
#endif
#include <dos.h>
#include <math.h>
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <graphics.h>
#define ESC 0x1b /* Define the escape key */
#define TRUE 1 /* Define some handy constants */
#define FALSE 0 /* Define some handy constants */
#define PI 3.14159 /* Define a value for PI */
#define ON 1 /* Define some handy constants */
#define OFF 0 /* Define some handy constants */
char *Fonts[] = {
"DefaultFont", "TriplexFont", "SmallFont",
"SansSerifFont", "GothicFont"
};
char *LineStyles[] = {
"SolidLn", "DottedLn", "CenterLn", "DashedLn", "UserBitLn"
};
char *FillStyles[] = {
"EmptyFill", "SolidFill", "LineFill", "LtSlashFill",
"SlashFill", "BkSlashFill", "LtBkSlashFill", "HatchFill",
"XHatchFill", "InterleaveFill", "WideDotFill", "CloseDotFill"
};
char *TextDirect[] = {
"HorizDir", "VertDir"
};
char *HorizJust[] = {
"LeftText", "CenterText", "RightText"
};
char *VertJust[] = {
"BottomText", "CenterText", "TopText"
};
struct PTS {
int x, y;
}; /* Structure to hold vertex points */
int GraphDriver; /* The Graphics device driver */
int GraphMode; /* The Graphics mode value */
double AspectRatio; /* Aspect ratio of a pixel on the screen*/
int MaxX, MaxY; /* The maximum resolution of the screen */
int MaxColors; /* The maximum # of colors available */
int ErrorCode; /* Reports any graphics errors */
struct palettetype palette; /* Used to read palette info */
/* */
/* Function prototypes */
/* */
void Initialize(void);
void ReportStatus(void);
void TextDump(void);
void Bar3DDemo(void);
void RandomBars(void);
void TextDemo(void);
void ColorDemo(void);
void ArcDemo(void);
void CircleDemo(void);
void PieDemo(void);
void BarDemo(void);
void LineRelDemo(void);
void PutPixelDemo(void);
void PutImageDemo(void);
void LineToDemo(void);
void LineStyleDemo(void);
void CRTModeDemo(void);
void UserLineStyleDemo(void);
void FillStyleDemo(void);
void FillPatternDemo(void);
void PaletteDemo(void);
void PolyDemo(void);
void SayGoodbye(void);
void Pause(void);
void MainWindow(char *header);
void StatusLine(char *msg);
void DrawBorder(void);
void changetextstyle(int font, int direction, int charsize);
int gprintf(int *xloc, int *yloc, char *fmt, ... );
/* */
/* Begin main function */
/* */
int main()
{
Initialize(); /* Set system into Graphics mode */
ReportStatus(); /* Report results of the initialization */
ColorDemo(); /* Begin actual demonstration */
if( GraphDriver==EGA || GraphDriver==EGALO || GraphDriver==VGA )
PaletteDemo();
PutPixelDemo();
PutImageDemo();
Bar3DDemo();
BarDemo();
RandomBars();
ArcDemo();
CircleDemo();
PieDemo();
LineRelDemo();
LineToDemo();
LineStyleDemo();
UserLineStyleDemo();
TextDump();
TextDemo();
CRTModeDemo();
FillStyleDemo();
FillPatternDemo();
PolyDemo();
SayGoodbye(); /* Give user the closing screen */
closegraph(); /* Return the system to text mode */
return(0);
}
/* */
/* INITIALIZE: Initializes the graphics system and reports */
/* any errors which occured. */
/* */
void Initialize(void)
{
int xasp, yasp; /* Used to read the aspect ratio*/
GraphDriver = DETECT; /* Request auto-detection */
initgraph( &GraphDriver, &GraphMode, "" );
ErrorCode = graphresult(); /* Read result of initialization*/
if( ErrorCode != grOk ){ /* Error occured during init */
printf(" Graphics System Error: %s\n", grapherrormsg( ErrorCode ) );
exit( 1 );
}
getpalette( &palette ); /* Read the palette from board */
MaxColors = getmaxcolor() + 1; /* Read maximum number of colors*/
MaxX = getmaxx();
MaxY = getmaxy(); /* Read size of screen */
getaspectratio( &xasp, &yasp ); /* read the hardware aspect */
AspectRatio = (double)xasp / (double)yasp; /* Get correction factor */
}
/* */
/* REPORTSTATUS: Report the current configuration of the system */
/* after the auto-detect initialization. */
/* */
void ReportStatus(void)
{
struct viewporttype viewinfo; /* Params for inquiry procedures*/
struct linesettingstype lineinfo;
struct fillsettingstype fillinfo;
struct textsettingstype textinfo;
struct palettetype palette;
char *driver, *mode; /* Strings for driver and mode */
int x, y;
getviewsettings( &viewinfo );
getlinesettings( &lineinfo );
getfillsettings( &fillinfo );
gettextsettings( &textinfo );
getpalette( &palette );
x = 10;
y = 4;
MainWindow( "Status report after InitGraph" );
settextjustify( LEFT_TEXT, TOP_TEXT );
driver = getdrivername();
mode = getmodename(GraphMode); /* get current setting */
gprintf( &x, &y, "Graphics device : %-20s (%d)", driver, GraphDriver );
gprintf( &x, &y, "Graphics mode : %-20s (%d)", mode, GraphMode );
gprintf( &x, &y, "Screen resolution : ( 0, 0, %d, %d )", getmaxx(), getmaxy() );
gprintf( &x, &y, "Current view port : ( %d, %d, %d, %d )",
viewinfo.left, viewinfo.top, viewinfo.right, viewinfo.bottom );
gprintf( &x, &y, "Clipping : %s", viewinfo.clip ? "ON" : "OFF" );
gprintf( &x, &y, "Current position : ( %d, %d )", getx(), gety() );
gprintf( &x, &y, "Colors available : %d", MaxColors );
gprintf( &x, &y, "Current color : %d", getcolor() );
gprintf( &x, &y, "Line style : %s", LineStyles[ lineinfo.linestyle ] );
gprintf( &x, &y, "Line thickness : %d", lineinfo.thickness );
gprintf( &x, &y, "Current fill style : %s", FillStyles[ fillinfo.pattern ] );
gprintf( &x, &y, "Current fill color : %d", fillinfo.color );
gprintf( &x, &y, "Current font : %s", Fonts[ textinfo.font ] );
gprintf( &x, &y, "Text direction : %s", TextDirect[ textinfo.direction ] );
gprintf( &x, &y, "Character size : %d", textinfo.charsize );
gprintf( &x, &y, "Horizontal justify : %s", HorizJust[ textinfo.horiz ] );
gprintf( &x, &y, "Vertical justify : %s", VertJust[ textinfo.vert ] );
Pause(); /* Pause for user to read screen*/
}
/* */
/* TEXTDUMP: Display the all the characters in each of the */
/* available fonts. */
/* */
void TextDump()
{
static int CGASizes[] = {
1, 3, 7, 3, 3 };
static int NormSizes[] = {
1, 4, 7, 4, 4 };
char buffer[80];
int font, ch, wwidth, lwidth, size;
struct viewporttype vp;
for( font=0 ; font<5 ; ++font ){ /* For each available font */
sprintf( buffer, "%s Character Set", Fonts[font] );
MainWindow( buffer ); /* Display fontname as banner */
getviewsettings( &vp ); /* read current viewport */
settextjustify( LEFT_TEXT, TOP_TEXT );
moveto( 2, 3 );
buffer[1] = '\0'; /* Terminate string */
wwidth = vp.right - vp.left; /* Determine the window width */
lwidth = textwidth( "H" ); /* Get average letter width */
if( font == DEFAULT_FONT ){
changetextstyle( font, HORIZ_DIR, 1 );
ch = 0;
while( ch < 256 ){ /* For each possible character */
buffer[0] = ch; /* Put character into a string */
outtext( buffer ); /* send string to screen */
if( (getx() + lwidth) > wwidth )
moveto( 2, gety() + textheight("H") + 3 );
++ch; /* Goto the next character */
}
}
else{
size = (MaxY < 200) ? CGASizes[font] : NormSizes[font];
changetextstyle( font, HORIZ_DIR, size );
ch = '!';
没有合适的资源?快使用搜索试试~ 我知道了~
Turbo C2.0 C语言编译工具
共113个文件
h:31个
c:14个
lib:13个
需积分: 10 51 下载量 157 浏览量
2008-10-07
19:54:26
上传
评论 1
收藏 966KB RAR 举报
温馨提示
TC2.0虽然是很古老的工具,但是对于初学者来说,使用这个工具更有利于学习更纯正的标准毕尔C语言。
资源推荐
资源详情
资源评论
收起资源包目录
Turbo C2.0 C语言编译工具 (113个子文件)
RULES.ASI 11KB
EMUVARS.ASI 5KB
C0.ASM 21KB
SETARGV.ASM 16KB
SETENVP.ASM 2KB
BUILD-C0.BAT 663B
IBM8514.BGI 7KB
ATT.BGI 6KB
CGA.BGI 6KB
HERC.BGI 6KB
PC3270.BGI 6KB
EGAVGA.BGI 5KB
BGIDEMO.C 39KB
MCOMMAND.C 19KB
MCUTIL.C 15KB
MCPARSER.C 12KB
MCDISPLY.C 7KB
MATHERR.C 5KB
CBAR.C 4KB
MCINPUT.C 4KB
WORDCNT.C 4KB
SSIGNAL.C 4KB
MCALC.C 4KB
CPASDEMO.C 2KB
MAIN.C 1KB
HELLO.C 104B
TURBOC.CFG 40B
GOTH.CHR 8KB
TRIP.CHR 7KB
SANS.CHR 5KB
LITT.CHR 2KB
OBJXREF.COM 30KB
THELP.COM 28KB
GREP.COM 7KB
README.COM 4KB
TOUCH.COM 4KB
WORDCNT.DAT 1KB
HELPME!.DOC 18KB
THELP.DOC 12KB
MCALC.DOC 2KB
TC.EXE 283KB
TCC.EXE 176KB
TCINST.EXE 78KB
CPP.EXE 58KB
1.EXE 49KB
TLIB.EXE 30KB
MAKE.EXE 27KB
TLINK.EXE 21KB
CINSTXFR.EXE 18KB
TCCONFIG.EXE 15KB
BGIOBJ.EXE 12KB
HELLO.EXE 9KB
GRAPHICS.H 12KB
DOS.H 8KB
MCALC.H 8KB
STDIO.H 7KB
STDLIB.H 4KB
FLOAT.H 4KB
MATH.H 3KB
ERRNO.H 3KB
IO.H 2KB
CONIO.H 2KB
STRING.H 2KB
PROCESS.H 2KB
DIR.H 1KB
ALLOC.H 1KB
MALLOC.H 1KB
CTYPE.H 1KB
FCNTL.H 1KB
MEM.H 1KB
SIGNAL.H 1KB
TIME.H 1KB
STAT.H 1020B
VALUES.H 996B
LIMITS.H 762B
STDDEF.H 672B
SETJMP.H 547B
BIOS.H 532B
STDARG.H 469B
SHARE.H 439B
TIMEB.H 425B
ASSERT.H 414B
TYPES.H 193B
CL.LIB 108KB
CM.LIB 105KB
CC.LIB 105KB
CH.LIB 105KB
CS.LIB 102KB
GRAPHICS.LIB 29KB
MATHL.LIB 21KB
MATHC.LIB 21KB
MATHM.LIB 21KB
MATHS.LIB 20KB
MATHH.LIB 20KB
EMU.LIB 15KB
FP87.LIB 3KB
C0M.OBJ 2KB
C0S.OBJ 2KB
C0T.OBJ 2KB
C0L.OBJ 2KB
共 113 条
- 1
- 2
资源评论
jiangjun2hao
- 粉丝: 0
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功