美丽心灵公益论坛

查看: 2793|回复: 6

我懂得彩色编程了(Windows)

[复制链接]
累计签到:30 天
连续签到:4 天

22

主题

394

回帖

2844

积分

金牌会员

Rank: 6Rank: 6

积分
2844
发表于 2022-8-7 18:27:23| 字数 265 | 显示全部楼层 |阅读模式
本帖最后由 孤星1 于 2022-8-12 15:32 编辑






一个是用ESC[<n>m 的ANSI代码,一个是直接调用Win32 API, SetConsoleTextAttribute.
我用的是C++. (这里就不放源代码了)

Python好像也是用ANSI代码,其他语言如Visual Basic .NET就比较简单,如:

  1. Console.ForegroundColor = ConsoleColor.Red;
  2. Console.Write("Hello World");
复制代码
你们是如何用你的程序语言在终端窗口显示含彩色的文字?

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
累计签到:1551 天
连续签到:2 天

543

主题

6514

回帖

518万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
5188342

活跃会员热心会员发帖达人最佳新人

活跃会员
发表于 2022-8-7 18:38:10| 字数 16 | 显示全部楼层
css里的color属性了解一下
累计签到:3 天
连续签到:1 天

466

主题

5137

回帖

2万

积分

超级版主

Rank: 8Rank: 8

积分
23862

最佳新人活跃会员发帖达人

最佳新人
发表于 2022-8-7 19:01:05| 字数 4 | 显示全部楼层
加油加油
累计签到:30 天
连续签到:4 天

22

主题

394

回帖

2844

积分

金牌会员

Rank: 6Rank: 6

积分
2844
 楼主| 发表于 2022-8-7 19:14:19| 字数 55 | 显示全部楼层
simonzhd 发表于 2022-8-7 18:38
css里的color属性了解一下

CSS的,我也略知一二,哈哈。
累计签到:30 天
连续签到:4 天

22

主题

394

回帖

2844

积分

金牌会员

Rank: 6Rank: 6

积分
2844
 楼主| 发表于 2022-8-7 19:14:35| 字数 28 | 显示全部楼层

谢谢鼓励!
累计签到:30 天
连续签到:4 天

22

主题

394

回帖

2844

积分

金牌会员

Rank: 6Rank: 6

积分
2844
 楼主| 发表于 2022-8-8 15:09:11| 字数 680 | 显示全部楼层
本帖最后由 孤星1 于 2022-8-12 15:32 编辑



  1.     printf("\x1b[48;5;10mWelcome to coloring in Windows.\r\n");
  2.     printf("\x1b[48;5;20mWelcome to coloring in Windows.\r\n");
  3.     printf("\x1b[48;5;30mWelcome to coloring in Windows.\r\n");
  4.     printf("\x1b[48;5;40mWelcome to coloring in Windows.\r\n");
  5.     printf("\x1b[48;5;50mWelcome to coloring in Windows.\r\n");
  6.     printf("\x1b[48;5;60mWelcome to coloring in Windows.\r\n");
  7.     printf("\x1b[48;5;70mWelcome to coloring in Windows.\r\n");
  8.     printf("\x1b[48;5;80mWelcome to coloring in Windows.\r\n");
  9.     printf("\x1b[48;5;90mWelcome to coloring in Windows.\r\n");
  10.     printf("\x1b[48;5;100mWelcome to coloring in Windows.\r\n");
复制代码


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
累计签到:3 天
连续签到:1 天

466

主题

5137

回帖

2万

积分

超级版主

Rank: 8Rank: 8

积分
23862

最佳新人活跃会员发帖达人

最佳新人
发表于 2022-8-8 15:26:05| 字数 9 | 显示全部楼层
又有新进展了,不错
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|免责及版权声明|关于|美丽心灵公益论坛

GMT+8, 2025-12-12 18:08 , Processed in 0.086635 second(s), 37 queries .

Powered by Discuz! X3.4

!copyright!

快速回复 返回顶部 返回列表