输出技巧
  • 板块灌水区
  • 楼主aka_ms
  • 当前回复0
  • 已保存回复0
  • 发布时间2025/1/4 15:29
  • 上次更新2025/1/4 15:44:21
查看原帖
输出技巧
1355634
aka_ms楼主2025/1/4 15:29
#include<windows.h>
#include<iostream>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<conio.h>

typedef struct color{
	unsigned int r,g,b;
}color;
void rgb_init(){
	HANDLE hIn = GetStdHandle(STD_INPUT_HANDLE);	HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
	DWORD dwInMode, dwOutMode;
	GetConsoleMode(hIn, &dwInMode);	GetConsoleMode(hOut, &dwOutMode);
	dwInMode |= 0x0200;	dwOutMode |= 0x0004;
	SetConsoleMode(hIn, dwInMode);	SetConsoleMode(hOut, dwOutMode);
}
void rgb_set(int wr,int wg,int wb,int br,int bg,int bb){
	printf("\033[38;2;%d;%d;%dm\033[48;2;%d;%d;%dm",wr,wg,wb,br,bg,bb);
}
void rgb_set(color front,color behind){
	printf("\033[38;2;%d;%d;%dm\033[48;2;%d;%d;%dm",front.r,front.g,front.b,behind.r,behind.g,behind.b);
}
void rgb_set(std::string front,std::string behind){
	int wr=0,wg=0,wb=0,br=0,bg=0,bb=0;
	if(front=="red"){
		wr=255;wg=0;wb=0;
	}else if(front=="orange"){
		wr=233;wg=51;wb=44;
	}else if(front=="yellow"){
		wr=254;wg=196;wb=69;
	}else if(front=="green"){
		wr=30;wg=196;wb=47;
	}else if(front=="blue"){
		wr=14;wg=118;wb=226;
	}else if(front=="purple"){
		wr=185;wg=37;wb=245;
	}else if(front=="white"){
		wr=255;wg=255;wb=255;
	}else if(front=="black"){
		wr=0;wg=0;wb=0;
	}
	
	if(behind=="red"){
		br=255;bg=0;bb=0;
	}else if(behind=="orange"){
		br=233;bg=51;bb=44;
	}else if(behind=="yellow"){
		br=254;bg=196;bb=69;
	}else if(behind=="green"){
		br=30;bg=196;bb=47;
	}else if(behind=="blue"){
		br=14;bg=118;bb=226;
	}else if(behind=="purple"){
		br=185;bg=37;bb=245;
	}else if(behind=="white"){
		br=255;bg=255;bb=255;
	}else if(behind=="black"){
		br=0;bg=0;bb=0;
	}
	printf("\033[38;2;%d;%d;%dm\033[48;2;%d;%d;%dm",wr,wg,wb,br,bg,bb);
}
void rgb_set(std::string ipt){
	if(ipt=="error"){
		printf("\033[38;2;%d;%d;%dm\033[48;2;%d;%d;%dm",255,0,0,254,196,99);
	}else if(ipt=="normal"){
		printf("\033[38;2;%d;%d;%dm\033[48;2;%d;%d;%dm",255,255,255,0,0,0);
	}else if(ipt=="high_light"){
		printf("\033[38;2;%d;%d;%dm\033[48;2;%d;%d;%dm",0,0,0,255,255,255);
	}
}
void gotoxy(int x,int y){ COORD c; c.X=x-1; c.Y=y-1; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),c); }

int main(){
		return 0;
}
2025/1/4 15:29
加载中...