[Selected] New Year's greetings (C language), Easyx graphics library application + source code sharing

[Selected] New Year's greetings (C language), Easyx graphics library application + source code sharing


Blogger: Light of Destiny
Column: Easyx Graphics Library Application

program display

Text can be entered freely.
The input format is: English double quotation marks "+ text (four words) + text (four words) + English double quotation marks"

insert image description here

1. Project environment

1. Visual Studio 2022
2. Install the easyx graphics library, you can call the header file

#include<easyx.h>

A brief introduction to the easyx graphics library

The EasyX library is a graphical interface library based on C language, which can be used for the development of graphical interface application programs under the Windows operating system. This library provides some easy-to-use graphics drawing functions and simple event processing functions, which can help developers quickly create various graphics applications, such as games, graphics editors, etc.
The EasyX library provides a wealth of drawing functions, such as the drawing of basic shapes such as straight lines, rectangles, circles, ellipses, and polygons. It also supports the loading and processing of various media resources such as pictures, text, and audio. In addition, the EasyX library also supports the processing of various events such as mouse and keyboard, allowing users to interact with applications.
Another feature of the EasyX library is that it is easy to learn and use. It provides a simple API, making it easy for beginners to get started, and has rich online documentation and sample programs to help developers quickly learn and understand how to use this library. In addition, the EasyX library can also be used in conjunction with common integrated development environments such as Visual Studio to make the development work more efficient.
In short, the EasyX library is an easy-to-use, powerful graphical interface library, suitable for beginners and developers with a certain programming foundation, and can be used to quickly develop various graphical applications.

Easyx graphics library

Click to jump to the official website of easyx graphics library download

Operation effect display (video)

new year wishes

Program source code sharing

#include<stdio.h>
#include<graphics.h>
#include<easyx.h>
#include<iostream>
#include<string.h>
using namespace std;
#define Maxsize 50
void henpi();
typedef struct {
    
    
	const char* pstr;
	char ch[Maxsize];
	int length;
}sqlist;
sqlist L;
void mune()
{
    
    
	printf("/*-----------------------*/\n");
	printf("----1.输入新年祝福语!----\n");
	printf("----2.删除祝福语(重新输入)!----\n");
	printf("/*-----------------------*/\n");
}
void initlist(sqlist & L)
{
    
    
	for (int i = 0; i < Maxsize;i++)
	{
    
    
		L.ch[i] = 0;
    }
	L.length = 0;
	L.pstr = L.ch;
	
}
void xieru(sqlist& L)
{
    
    
	for (int i = 0; i < 20; i++)
	{
    
    
		cout << "输入第"<<i<<"个数" << endl;
		cin >> L.ch[i];
		L.length++;
		cleardevice();
		RECT rect;
		rect.left = -500;
		rect.top = 150;
		rect.right = 500;
		rect.bottom = -150;
		//setfillcolor(WHITE);
		//fillrectangle(-500,150,500,-150);
		settextstyle(100, 0, "微软雅黑");
		LOGFONT fontstyle;
		gettextstyle(&fontstyle);
		fontstyle.lfQuality = ANTIALIASED_QUALITY;
		settextstyle(&fontstyle);
		for (int i = 0; i < L.length; i++)
		{
    
    
			henpi();
			settextcolor(WHITE);
			settextstyle(120, 0, "微软雅黑");
			drawtext(L.pstr, &rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
			Sleep(30);			//使程序间断0.3秒。
		}
		cout << L.length << endl;
		cout << "传入成功"<<endl;

	}
}
void henpi()
{
    
    
	RECT rt;
	rt.left = -350;
	rt.top = -250;
	rt.right = 350;
	rt.bottom = -150;
	settextstyle(60, 0, "微软雅黑");
	LOGFONT fontstyle;
	gettextstyle(&fontstyle);
	fontstyle.lfQuality = ANTIALIASED_QUALITY;
	settextstyle(&fontstyle);
	const char* pstr = "2023新年祝福";
	settextcolor(YELLOW);
	drawtext(pstr, &rt, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
}
int main()
{
    
    
	sqlist L;
	initlist(L);
	/*RECT rect;
	rect.left = -500;
	rect.top = 100;
	rect.right = 500;
	rect.bottom = -100;*/
	initgraph(1400, 800, EW_SHOWCONSOLE);
	setbkcolor(RED);//红色背景
	cleardevice();
	setorigin(700, 400);
	while (1)
	{
    
    
		int n; 
		mune();
		henpi();
		cin >> n;
		switch (n)
		{
    
    
			case 1:xieru(L);
				break;
			case 2:initlist(L);
				break;
		}
	}
	getchar();
	closegraph();
	return 0;
}

Send out the program I wrote before and share it with you.

Guess you like

Origin blog.csdn.net/VLOKL/article/details/130655990