Character Matrix

The program demonstrates common drawing operations, including setting fonts, drawing lines, and so on.

// Compiler Env: Visual C++ 6.0~2022,EasyX_2023大暑版
// https://easyx.cn
//
#include <graphics.h>
#include <time.h>
#include <conio.h>

int main()
{
	// Set random seed
	srand((unsigned) time(NULL));

	// Create a graphics window
	initgraph(640, 480);

	int  x, y;
	char c;

	settextstyle(16, 8, _T("Courier"));	// Set text style

	// Set text and line color
	settextcolor(GREEN);
	setlinecolor(BLACK);

	for (int i = 0; i <= 479; i++)
	{
		// Display three random letters in random positions
		for (int j = 0; j < 3; j++)
		{
			x = (rand() % 80) * 8;
			y = (rand() % 20) * 24;
			c = (rand() % 26) + 65;
			outtextxy(x, y, c);
		}

		// Draw a line and erase a pixel row
		line(0, i, 639, i);

		Sleep(10);					// Delay
		if (i >= 479)	i = -1;
		if (_kbhit())	break;		// Press any key to exit
	}

	// Close the graphics window
	closegraph();
	return 0;
}

For more examples, please refer to https://codebus.cn

(贡献者:Krissi  编辑