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

📄 mwstart1.c

📁 nucleus 文件系统,内核和彩色图形系统,在小系统上非常好用
💻 C
字号:
/*  %kw # %v    %n    %d    %t #                         */
/*  Version # 2    MWSTART1.C    9-Jul-92    15:43:08 #    */
/**********************************************************/
/* CHAPTER 2, Section 1 Example                           */
/*                                                        */
/* Description: initializes the MetaWINDOW graphics       */
/* system, then draws some objects and text to the screen */
/*                                                        */
/* Functions used:                                        */
/* InitGraphic, StopGraphics, SetDisplay, MoveTo, LineTo, */
/* FrameRect, FillRect, FramOval, FillOval, DrawString    */
/**********************************************************/
#define byte unsigned char
#define word unsigned short

#include <stdio.h>
#include <stdlib.h>
//#include <conio.h>
#include "metawndo.h"      /* master MetaWINDOW include file */

/* special stack size declaration if using Turbo or Borland C++ */
#ifdef      TurboC
extern unsigned _stklen = 14336U;  /* set stack size to 14K */
#endif /*TurboC*/
void Waiting(int a);


void mwstart1()
{
	void quit(void);
   int   lStartX, lStartY, lEndX, lEndY;
   int   rStartX, rStartY, rEndX, rEndY;
   rect  frame_rect, fill_rect;      /* declare some rectangle structures */
   rect  frame_oval, fill_oval;      /* declare some rectangle structures */
   rect  scrnSize;
   grafPort     penPort;
	mwEvent waitEvent;

//        /* initialize the MetaWINDOW graphics system 
//   for the IBM CGA 640x200 2 color mode      */
//   i = InitGraphics( CGA640x200 );
//   if( i != 0 ) {
//      printf( "MetaWINDOW InitGrafix error - %d\n",i );
//      exit(1);
//   }

//   SetDisplay( GrafPg0 );     /* switch to graphics mode   */

   ScreenRect( &scrnSize);
   BackColor(0);
   EraseRect( &scrnSize);
   PenNormal();
   lStartX = (scrnSize.Xmax + 1) / 64;
   if(lStartX < 2) lStartX = 2;
   lStartY = (scrnSize.Ymax + 1) / 64;
   if(lStartY < 2) lStartY = 2;
   lEndX = (scrnSize.Xmax + 1) / 10;
   lEndY = (scrnSize.Ymax + 1) / 12;
   MoveTo( lStartX,lStartY );           /* start at x/y coordinate   */
   LineTo( lEndX,lEndY );          /* draw a line to x/y coord  */

	/* set-up some rectangle sizes and locations */
   rStartX = lStartX;
   rStartY = lEndY + lStartY;
   rEndX = 15 * lStartX;
   rEndY = rStartY + 9 * lStartY;
   SetRect( &frame_rect, rStartX,rStartY, rEndX,rEndY );
   SetRect( &frame_oval,rStartX,rEndY + lStartY, rEndX,rStartY + rEndY + lStartY);
   rEndX += (16 * rStartX);
   rStartX += (16 * rStartX);
   SetRect( &fill_rect, rStartX,rStartY, rEndX,rEndY );
   SetRect( &fill_oval, rStartX,rEndY + lStartY, rEndX,rStartY + rEndY + lStartY);

	/* fill and frame a rectangle and oval */
	FrameRect( &frame_rect ); 
	FillRect( &fill_rect, 1 ); /* when filling an object, 1 = solid pattern */
	FrameOval( &frame_oval ); 
	FillOval( &fill_oval, 1 );

	/* draw some text to the graphics screen */
  GetPenState(&penPort);
	penPort.pnColor = 0;
	penPort.bkColor = -1;
	SetPenState(&penPort);
        MoveTo( lStartX + 16,lStartY + 8);
        DrawString( "NU_GRAFIX_SWEEP Sample Program 1" );
	PenNormal();
#ifndef CYCLE
	MoveTo( 0,scrnSize.Ymax - 20 );
	DrawString( "Press 'x' to exit" );
	MoveTo( 0,scrnSize.Ymax - 10 );
	DrawString( "any other key to continue" );
	  while(!KeyEvent(1, &waitEvent));
	  if((waitEvent.eventChar == 'x') || (waitEvent.eventChar == 'X')) quit();
#else
#ifdef _MNT_
	  KeyEvent(0, &waitEvent);
	  if((waitEvent.eventChar == 'x') || (waitEvent.eventChar == 'X')) quit();
#endif
   Waiting(150);
#endif
  return;      
}

/* End of File - CHAP2_1.C */

⌨️ 快捷键说明

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