基于C语言的。
#include<stdio.h>
#include<stdlib.h>
#include<tchar.h>
#include<windows.h>
extern "C" WINBASEAPI HWND WINAPI GetConsoleWindow ();//把控制台的句柄给hwnd
int main()
{
HWND hwnd;
HDC hdc;
HFONT font;
HPEN hPen;
HBRUSH hBrush;
char str[]="王旭";
hwnd = GetConsoleWindow();
hdc = GetDC(hwnd);
//system("color 3d");
font=CreateFont(70,70,0,0,FW_BOLD,TRUE,FALSE,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH|FF_SWISS,TEXT("微软雅黑")); //设置字体样式
hPen=CreatePen(PS_INSIDEFRAME,0,RGB(255,0,0)); //设置画笔颜色
hBrush=CreateSolidBrush(RGB(0,255,0));//设置画刷颜色
SelectObject(hdc,hPen);
SelectObject(hdc,font);
//SelectObject(hdc,hBrush);不用选择填充
SetBkColor(hdc,RGB(200,100,180)); //改变文本框背景色
SetTextColor(hdc,RGB(100,200,150)); //改变文本框中字体颜色
Rectangle(hdc,200,100,400,280);
//画三角形
MoveToEx(hdc,50,50,NULL);
LineTo(hdc,100,100);
LineTo(hdc,150,50);
LineTo(hdc,50,50);
//画直线
MoveToEx(hdc,200,50,NULL);
LineTo(hdc,300,50);
//画圆
Ellipse(hdc,10,100,110,200);
TextOut(hdc,50,300,str,sizeof(str));
//删除部分
DeleteObject(hPen);
DeleteObject(font);
DeleteObject(hBrush);
ReleaseDC(hwnd,hdc);
getchar();
return 0;
}