为了让颜色的明度的区分度加强,对颜色对比进行了改进和调整:
先看改进结果:
![](https://box.kancloud.cn/81d100bc392b016fb0770e93e65f44b7_1064x730.jpg)
``
数值注释如下:
![](https://box.kancloud.cn/aa7e63dfa17ad0d4b56353e46175c396_918x329.png)
代码如下:
```
case WM_PAINT:
{
PAINTSTRUCT ps;
HPEN hpen; // 画笔
HDC hdc = BeginPaint(hWnd, &ps);
// TODO: 在此处添加使用 hdc 的任何绘图代码...
//渲染画图
MoveToEx(hdc, 0,0,NULL);
int r = 0;
int g = 0;
int b = 0;
int ray = 0;
for (int i = 1; i < 999; ++i) { // 896; ++i) { //for100 //for (int i = 1; i < 1792; ++i) { //for100
if (0 == i) ray = 0;
MoveToEx(hdc, i, 0,NULL);
//暗灰
if ((0 < i) && (i <= 63) ) {//if110
++ray;
// 创建画笔
hpen = CreatePen(PS_SOLID, 1, RGB(ray, ray, ray));
SelectObject(hdc, hpen);
}//if110
//暗蓝-蓝
if ((64 <= i) && (i <= 191)) {//if120
++ray;
// 创建画笔
hpen = CreatePen(PS_SOLID, 1, RGB(0,0, 128+(i-64) ) );
SelectObject(hdc, hpen);
}//if120
//暗红-红
if ((192 <= i) && (i <= 319)) {//if120 //if ((384 < i) && (i <= 639)) {//if120
++ray;
// 创建画笔
hpen = CreatePen(PS_SOLID, 1, 64+ RGB( (i - 192),0,0 ));
SelectObject(hdc, hpen);
}//if120
//暗绿色63种
if ((320 <= i) && (i <= 383)) {//if210
++ray;
// 创建画笔
hpen = CreatePen(PS_SOLID, 1, RGB(0, 64 + (i - 64), 0));
SelectObject(hdc, hpen);
}//if210
//暗紫色-品色(红+蓝) 127种
else if ((384 <= i) && (i <= 511)) {//else if210 //if ((384<= i) && (i <= 511)) {//if120
++ray;
// 创建画笔
hpen = CreatePen(PS_SOLID, 1, RGB(128 + (i - 384), 127, 128+ (i - 384)));
SelectObject(hdc, hpen);
}//else if210
//暗紫色-品色(红+蓝) 127种
//明亮绿色 63种
if ((512 <= i) && (i <= 575)) {//if120
++ray;
// 创建画笔
hpen = CreatePen(PS_SOLID, 1, RGB( 0+(i-512), 192+ (i - 512), 0 +(i-512) ) ); //0+(i-512)增加明度,让亮绿更亮
SelectObject(hdc, hpen);
}//if120
//青色-(蓝+绿色) 127种
if (( 576 <= i) && (i <= 703)) {//if120
++ray;
// 创建画笔
hpen = CreatePen(PS_SOLID, 1, RGB( 0+(i-576) , 128+(i - 576), 128+(i - 576) ));
SelectObject(hdc, hpen);
}//if120
//明黄色-(红+绿色) 127种
if ((704 <= i) && (i <= 831)) {//if120
++ray;
// 创建画笔
hpen = CreatePen(PS_SOLID, 1, RGB( 128+(i - 704), 128+(i - 704) ,0+(i-704 ) ) );
SelectObject(hdc, hpen);
}//if120
//白色-(白色-高亮白) 64种……注解:再多就做 白切割 了……
if ((832 <= i) && (i <= 895)) {//if120 //if ((1664 <= i) ) {//if120
++ray;
// 创建画笔
hpen = CreatePen(PS_SOLID, 1, RGB( 192+(i - 831), 192+(i - 831), 192+(i - 831)));
SelectObject(hdc, hpen);
}//if120
//黑色-(太高亮) 64种……注解:再多就做 黑切割 了……
if ((895 <= i)) {//if120 //if ((1664 <= i) ) {//if120
++ray;
// 创建画笔
hpen = CreatePen(PS_SOLID, 1, RGB(0,0,0));
SelectObject(hdc, hpen);
}//if120
// SelectObject(hdc, hpen);
LineTo(hdc, 0, i); //LineTo(hdc, i, i);
}//for100
//
EndPaint(hWnd, &ps);
}
break;
case WM_DESTROY:
```