码迷,mamicode.com
首页 > 其他好文 > 详细

GDI+ 画渐变色环

时间:2014-07-11 00:24:19      阅读:750      评论:0      收藏:0      [点我收藏+]

标签:gdi+   vc++2005   color   360   

bubuko.com,布布扣


在onpaint() 函数中加入如下代码,本次利用DrawArc来实现。

#define PI 3.1415926
int angle=360;
int x=(rect.Width()-300)/2;
int y=190;
int width=300;
int hight=300;
int wide=34;

graphics.SetSmoothingMode(SmoothingModeAntiAlias);//抗锯齿

for(float i = 0.0; i < PI; i += (float)((float)PI/360)) {
float h,tc, tx;
float tr,tg,tb;
tr=tg=tb=1;
h = i*1.9;
tc = 1;
tx = tc * (1 - abs(fmod(h,2) - 1));
if(0 <= h && h < 1) {       tr = tc;   tg = tx;    tb = 0;   }
else if(1 <= h && h < 2) {  tr = tx;   tg = tc;    tb = 0;   }
else if(2 <= h && h < 3) {  tr = 0;    tg = tc;    tb = tx;  }
else if(3 <= h && h < 4) {  tr = 0;    tg = tx;    tb = tc;  }
else if(4 <= h && h < 5) {  tr = tx;   tg = 0;     tb = tc;  }
else if(5 <= h && h < 6) {  tr = tc;   tg = 0;     tb = tx;  }
tr = tr * 255;
tg = tg * 255;
tb = tb * 255;
Gdiplus::Pen pen(Color (255, (byte)tr, (byte)tg,(byte)tb ),wide);  
angle-=1;
graphics.DrawArc(&pen, x, y, width, hight, angle ,2);
}

GDI+ 画渐变色环,布布扣,bubuko.com

GDI+ 画渐变色环

标签:gdi+   vc++2005   color   360   

原文地址:http://blog.csdn.net/zjjyliuweijie/article/details/37598505

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!