当前位置: 首页 > article >正文

C++艺术字头文件:ArtText.h

最近写color()写飙了,想搞一个通用的艺术字函数,就媜出来一个ArtText.h。

        名字叫做ArtText.h

#ifndef ART_TEXT_H

#include <windows.h>
#include <bits/stdc++.h>

using namespace std;

HWND hWnd = GetConsoleWindow(); 

#define Art_Windows(bool)  bool ? SetWindowLong(hWnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW) : SetWindowLong(NULL, GWL_EXSTYLE, WS_EX_TOOLWINDOW)
#define Art_Title(string)	SetConsoleTitle(string)

void Art_Colour(int colors)
{
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), colors);
}

void Art_Text(string Text, string Behind, const char* Printf, int Wait_Time)
{
	int Behind_Size[16];
	int Behind_Size_Head[16] = {0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240};
	int Behind_Head;
	int Text_Size_Head[16] = {0, 1, 2, 3, 4, 80, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
	int Text_Head;
	if(Behind == "黑色")
		Behind_Head = Behind_Size_Head[0];
	if(Behind == "暗深蓝色")
		Behind_Head = Behind_Size_Head[1];
	if(Behind == "深绿色" || Behind == "暗绿色")
		Behind_Head = Behind_Size_Head[2];
	if(Behind == "暗淡蓝色")
		Behind_Head = Behind_Size_Head[3];
	if(Behind == "暗红色" || Behind == "深红色")
		Behind_Head = Behind_Size_Head[4];
	if(Behind == "暗紫色" || Behind == "深紫色")
		Behind_Head = Behind_Size_Head[5];
	if(Behind == "暗黄色" || Behind == "深黄色")
		Behind_Head = Behind_Size_Head[6];
	if(Behind == "浅灰色")
		Behind_Head = Behind_Size_Head[7];
	if(Behind == "深灰色")
		Behind_Head = Behind_Size_Head[8];
	if(Behind == "深蓝色" || Behind == "浅深蓝色")
		Behind_Head = Behind_Size_Head[9];
	if(Behind == "绿色" || Behind == "浅绿色")
		Behind_Head = Behind_Size_Head[10];
	if(Behind == "蓝色" || Behind == "浅蓝色")
		Behind_Head = Behind_Size_Head[11];
	if(Behind == "红色" || Behind == "浅红色")
		Behind_Head = Behind_Size_Head[12];
	if(Behind == "紫色" || Behind == "浅紫色")
		Behind_Head = Behind_Size_Head[13];
	if(Behind == "黄色" || Behind == "浅黄色")
		Behind_Head = Behind_Size_Head[14];
	if(Behind == "白色" || Behind == "浅白色")
		Behind_Head = Behind_Size_Head[15];
	if(Text == "黑色")
		Text_Head = Text_Size_Head[0];
	if(Text == "暗深蓝色")
		Text_Head = Text_Size_Head[1];
	if(Text == "深绿色" || Text == "暗绿色")
		Text_Head = Text_Size_Head[2];
	if(Text == "暗淡蓝色")
		Text_Head = Text_Size_Head[3];
	if(Text == "暗红色" || Text == "深红色")
		Text_Head = Text_Size_Head[4];
	if(Text == "暗紫色" || Text == "深紫色")
		Text_Head = Text_Size_Head[5];
	if(Text == "暗黄色" || Text == "深黄色")
		Text_Head = Text_Size_Head[6];
	if(Text == "浅灰色")
		Text_Head = Text_Size_Head[7];
	if(Text == "深灰色")
		Text_Head = Text_Size_Head[8];
	if(Text == "深蓝色" || Text == "浅深蓝色")
		Text_Head = Text_Size_Head[9];
	if(Text == "绿色" || Text == "浅绿色")
		Text_Head = Text_Size_Head[10];
	if(Text == "蓝色" || Text == "浅蓝色")
		Text_Head = Text_Size_Head[11];
	if(Text == "红色" || Text == "浅红色")
		Text_Head = Text_Size_Head[12];
	if(Text == "紫色" || Text == "浅紫色")
		Text_Head = Text_Size_Head[13];
	if(Text == "黄色" || Text == "浅黄色")
		Text_Head = Text_Size_Head[14];
	if(Text == "白色" || Text == "浅白色")
		Text_Head = Text_Size_Head[15];
	for(int i = Behind_Head; i <= Behind_Head + 15; i++)
		Behind_Size[i - Behind_Head] = i;
	int Size = Behind_Size[Text_Head];
    while (1)
    {
    	Art_Colour(Size);
        if (*Printf != 0)
        {
        	printf("%c", *Printf++);
        }
        else
        {
            break;
        }
        _sleep(Wait_Time);
        Size++;
    }
}

#endif

Define

Art_Window(判断真假Bool类型)   //如果是真,窗口改变成尖方窗口,否则返回0。

Art_Title(标题名称string类型)   //更改窗口标题。

Void

Art_Colour(色号¹int类型)   //改变颜色

Art_Text(字体颜色string类型(汉字), 背景颜色string类型(汉字), 输出内容string类型, 间隔时间int类型(单位毫秒))


¹色号:


http://www.kler.cn/a/231520.html

相关文章:

  • ### 哋它亢在5G基站中的应用:新兴技术与未来通信的融合
  • Ascend C算子性能优化实用技巧05——API使用优化
  • 如何在 Ubuntu 上安装 Jupyter Notebook
  • Cherno OpenGL(28 ~ 33)
  • Vue模块化开发的理解
  • 多模态基础模型:从专家到通用助手
  • PyTorch深度学习实战(23)——从零开始实现SSD目标检测
  • Debian系统显示中文
  • Unity SRP 管线【第十讲:SRP/URP 图形API】
  • HCIA-HarmonyOS设备开发认证V2.0-3.2.轻量系统内核基础-任务管理
  • shell脚本基础语法(.sh ./ sh bash source shell)
  • 彻底学会系列:一、机器学习之线性回归(一)
  • nginx slice模块的使用和源码分析
  • 保证 scope=session 的 fixture 在多进程运行情况下仍然能只运行一次
  • 项目02《游戏-09-开发》Unity3D
  • Leetcode 139 单词拆分
  • 【人工智能】神奇的Embedding:文本变向量,大语言模型智慧密码解析(10)
  • JWT令牌
  • React+Echarts实现数据排名+自动滚动+Y轴自定义toolTip文字提示
  • 【TCP】高频面试题
  • IMU模型介绍
  • ubuntu 没有屏幕安装QT(SSH远程登陆下)
  • HarmonyOS开发工具DevEco Studio安装以及汉化
  • 发廊理发店微信小程序展示下单前端静态模板源码
  • 15.2 Linux入门(❤❤❤❤)
  • 【Unity】QFramework通用背包系统优化:使用Odin优化编辑器