GDI+绘制渐变色
2015-07-07 00:01
295 查看
例1:
void CTextDlg::OnPaint()
{
Graphics graphics(this->m_hWnd);
LinearGradientBrush linGrBrush(
Point(0,0),
Point(200,0),
Color(255,255,0,0),
Color(255,0,0,255));
graphics.FillRectangle(&linGrBrush, 0, 0, 200, 200);
}
例2:
Graphics graphics(dc.GetSafeHdc());
graphics.Clear(Color::White);
//定义三种参与渐变的色彩
Color colors[] =
{
Color::Red, // 红色
Color::Green,//过渡色为绿色
Color::Blue // 蓝色
};
float positions[] =
{
0.0f, // 由红色起
0.3f, // 绿色始于画刷长度的三分之一
1.0f // 到蓝色止
};
//构造一条从黑色到白色的渐变画刷
LinearGradientBrush linGrBrush(
Point(0, 0),
Point(180, 0),
Color::Black,Color::White);
//设置渐变画刷的多色渐变信息
//linGrBrush.InterpolationColors=clrBlend;
linGrBrush.SetInterpolationColors(colors, positions, 3);
//使用多色渐变画刷填充目标区域
graphics.FillRectangle(&linGrBrush, 0, 0, 180, 100);
//使用普通的方法实现多色渐变
//由红到绿,长度60
LinearGradientBrush linGrBrush1(
Point(0, 0),
Point(60, 0),
Color::Red,
Color::Green);
//由绿到蓝,长度120
LinearGradientBrush linGrBrush2(
Point(60, 0),
Point(181, 0),
Color::Green,
Color::Blue);
//分别使用两个画刷填充两个相邻区域,形成多色渐变
graphics.FillRectangle(&linGrBrush1, 0, 120, 60, 100);
graphics.FillRectangle(&linGrBrush2, 60, 120, 120, 100);
void CTextDlg::OnPaint()
{
Graphics graphics(this->m_hWnd);
LinearGradientBrush linGrBrush(
Point(0,0),
Point(200,0),
Color(255,255,0,0),
Color(255,0,0,255));
graphics.FillRectangle(&linGrBrush, 0, 0, 200, 200);
}
例2:
Graphics graphics(dc.GetSafeHdc());
graphics.Clear(Color::White);
//定义三种参与渐变的色彩
Color colors[] =
{
Color::Red, // 红色
Color::Green,//过渡色为绿色
Color::Blue // 蓝色
};
float positions[] =
{
0.0f, // 由红色起
0.3f, // 绿色始于画刷长度的三分之一
1.0f // 到蓝色止
};
//构造一条从黑色到白色的渐变画刷
LinearGradientBrush linGrBrush(
Point(0, 0),
Point(180, 0),
Color::Black,Color::White);
//设置渐变画刷的多色渐变信息
//linGrBrush.InterpolationColors=clrBlend;
linGrBrush.SetInterpolationColors(colors, positions, 3);
//使用多色渐变画刷填充目标区域
graphics.FillRectangle(&linGrBrush, 0, 0, 180, 100);
//使用普通的方法实现多色渐变
//由红到绿,长度60
LinearGradientBrush linGrBrush1(
Point(0, 0),
Point(60, 0),
Color::Red,
Color::Green);
//由绿到蓝,长度120
LinearGradientBrush linGrBrush2(
Point(60, 0),
Point(181, 0),
Color::Green,
Color::Blue);
//分别使用两个画刷填充两个相邻区域,形成多色渐变
graphics.FillRectangle(&linGrBrush1, 0, 120, 60, 100);
graphics.FillRectangle(&linGrBrush2, 60, 120, 120, 100);
相关文章推荐
- Java
- Java
- Java
- Java实战案例课程
- 安卓软件开发教程
- 【中服OA】OA系统在企业发展过程中发挥着不可或缺的作用
- 选择传统软件还是SaaS服务,企业考虑四个因素
- In our lifestyle have a lot of sorts
- If your are possible and in very good
- At the to get started with component
- Ladies is extremely sensitive when
- 企业社交软件:微信合适吗?
- 企业通讯软件助力企业实现高效办公
- 润普易度文控管理在IT企业中的应用
- 【php】【集基础】【namespace】
- php curl 及其参数
- 天津专业建站公司
- Django
- Installation of vim plugin --- YouCompleteMe
- Object-Oriented Terms 面向对象术语