clock.c

来自「nucleus 文件系统,内核和彩色图形系统,在小系统上非常好用」· C语言 代码 · 共 113 行

C
113
字号
#define byte unsigned char
#define word unsigned short
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <math.h>
#include "metawndo.h"      /* master MetaWINDOW include file */




rect    sR,R;
void Waiting(int a);

void clockP(void)
{
	void quit(void);
   int      ScrnXmax,ScrnYmax,x,y,dx,dy,i,pat;
   int      maxclr;
//   long count;
   double clockAngle;
	mwEvent waitEvent;

   ScreenRect(&sR);
   RasterOp(zREPz);
   ScrnXmax = sR.Xmax;
   ScrnYmax = sR.Ymax;


   dx = (ScrnXmax)/2; dy=(ScrnYmax)/2;

   maxclr = (int) QueryColors();
   PenColor(maxclr);
   BackColor(0);
   EraseRect(&sR);
   pat = 7;
   clockAngle = 0.0;

   for (i = 0; i < 32; i++)
   {
   BackColor(4*i);
	   PenSize(4,4);
	   PenDash(pat);
	   PenPattern(pat);
	   MoveTo(dx, dy);
	   x = dx + (int)((float)dy * cos(clockAngle));
	   y = dy + (int)((float)dy * sin(clockAngle));
	   LineTo(x, y);
	   clockAngle = clockAngle + .196;
	   pat--;
	   if (pat < 0) pat = 7;
   }
   BackColor(0);
	MoveTo( dx,ScrnYmax - 10 );
	DrawString( "On/Off Dashes" );

#ifndef CYCLE
	MoveTo( 0,sR.Ymax - 20 );
	DrawString( "Press 'x' to exit" );
	MoveTo( 0,sR.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

   DashStyle(dashDouble);
   pat = 7;
   clockAngle = 0.0;

   for (i = 32; i < 64; i++)
   {
   BackColor(4*i);
	   PenSize(4,4);
	   PenDash(pat);
	   PenPattern(pat);
	   MoveTo(dx, dy);
	   x = dx + (int)((float)dy * cos(clockAngle));
	   y = dy + (int)((float)dy * sin(clockAngle));
	   LineTo(x, y);
	   clockAngle = clockAngle + .196;
	   pat--;
	   if (pat < 0) pat = 7;
   }
   BackColor(0);
	MoveTo( dx,ScrnYmax - 10 );
	DrawString( "Double Dashes" );

#ifndef CYCLE
	MoveTo( 0,sR.Ymax - 20 );
	DrawString( "Press 'x' to exit" );
	MoveTo( 0,sR.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; 
}


⌨️ 快捷键说明

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