当前位置:   article > 正文

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

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

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

        名字叫做ArtText.h

  1. #ifndef ART_TEXT_H
  2. #include <windows.h>
  3. #include <bits/stdc++.h>
  4. using namespace std;
  5. HWND hWnd = GetConsoleWindow();
  6. #define Art_Windows(bool) bool ? SetWindowLong(hWnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW) : SetWindowLong(NULL, GWL_EXSTYLE, WS_EX_TOOLWINDOW)
  7. #define Art_Title(string) SetConsoleTitle(string)
  8. void Art_Colour(int colors)
  9. {
  10. SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), colors);
  11. }
  12. void Art_Text(string Text, string Behind, const char* Printf, int Wait_Time)
  13. {
  14. int Behind_Size[16];
  15. int Behind_Size_Head[16] = {0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240};
  16. int Behind_Head;
  17. int Text_Size_Head[16] = {0, 1, 2, 3, 4, 80, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
  18. int Text_Head;
  19. if(Behind == "黑色")
  20. Behind_Head = Behind_Size_Head[0];
  21. if(Behind == "暗深蓝色")
  22. Behind_Head = Behind_Size_Head[1];
  23. if(Behind == "深绿色" || Behind == "暗绿色")
  24. Behind_Head = Behind_Size_Head[2];
  25. if(Behind == "暗淡蓝色")
  26. Behind_Head = Behind_Size_Head[3];
  27. if(Behind == "暗红色" || Behind == "深红色")
  28. Behind_Head = Behind_Size_Head[4];
  29. if(Behind == "暗紫色" || Behind == "深紫色")
  30. Behind_Head = Behind_Size_Head[5];
  31. if(Behind == "暗黄色" || Behind == "深黄色")
  32. Behind_Head = Behind_Size_Head[6];
  33. if(Behind == "浅灰色")
  34. Behind_Head = Behind_Size_Head[7];
  35. if(Behind == "深灰色")
  36. Behind_Head = Behind_Size_Head[8];
  37. if(Behind == "深蓝色" || Behind == "浅深蓝色")
  38. Behind_Head = Behind_Size_Head[9];
  39. if(Behind == "绿色" || Behind == "浅绿色")
  40. Behind_Head = Behind_Size_Head[10];
  41. if(Behind == "蓝色" || Behind == "浅蓝色")
  42. Behind_Head = Behind_Size_Head[11];
  43. if(Behind == "红色" || Behind == "浅红色")
  44. Behind_Head = Behind_Size_Head[12];
  45. if(Behind == "紫色" || Behind == "浅紫色")
  46. Behind_Head = Behind_Size_Head[13];
  47. if(Behind == "黄色" || Behind == "浅黄色")
  48. Behind_Head = Behind_Size_Head[14];
  49. if(Behind == "白色" || Behind == "浅白色")
  50. Behind_Head = Behind_Size_Head[15];
  51. if(Text == "黑色")
  52. Text_Head = Text_Size_Head[0];
  53. if(Text == "暗深蓝色")
  54. Text_Head = Text_Size_Head[1];
  55. if(Text == "深绿色" || Text == "暗绿色")
  56. Text_Head = Text_Size_Head[2];
  57. if(Text == "暗淡蓝色")
  58. Text_Head = Text_Size_Head[3];
  59. if(Text == "暗红色" || Text == "深红色")
  60. Text_Head = Text_Size_Head[4];
  61. if(Text == "暗紫色" || Text == "深紫色")
  62. Text_Head = Text_Size_Head[5];
  63. if(Text == "暗黄色" || Text == "深黄色")
  64. Text_Head = Text_Size_Head[6];
  65. if(Text == "浅灰色")
  66. Text_Head = Text_Size_Head[7];
  67. if(Text == "深灰色")
  68. Text_Head = Text_Size_Head[8];
  69. if(Text == "深蓝色" || Text == "浅深蓝色")
  70. Text_Head = Text_Size_Head[9];
  71. if(Text == "绿色" || Text == "浅绿色")
  72. Text_Head = Text_Size_Head[10];
  73. if(Text == "蓝色" || Text == "浅蓝色")
  74. Text_Head = Text_Size_Head[11];
  75. if(Text == "红色" || Text == "浅红色")
  76. Text_Head = Text_Size_Head[12];
  77. if(Text == "紫色" || Text == "浅紫色")
  78. Text_Head = Text_Size_Head[13];
  79. if(Text == "黄色" || Text == "浅黄色")
  80. Text_Head = Text_Size_Head[14];
  81. if(Text == "白色" || Text == "浅白色")
  82. Text_Head = Text_Size_Head[15];
  83. for(int i = Behind_Head; i <= Behind_Head + 15; i++)
  84. Behind_Size[i - Behind_Head] = i;
  85. int Size = Behind_Size[Text_Head];
  86. while (1)
  87. {
  88. Art_Colour(Size);
  89. if (*Printf != 0)
  90. {
  91. printf("%c", *Printf++);
  92. }
  93. else
  94. {
  95. break;
  96. }
  97. _sleep(Wait_Time);
  98. Size++;
  99. }
  100. }
  101. #endif

Define

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

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

Void

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

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


¹色号:

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/84940
推荐阅读
相关标签
  

闽ICP备14008679号