打造属于自已的图形(一) 绘图基础
2008-12-12 00:34
357 查看
作者: furenjun
本文内容:
一. 认识 System.Drawing类
二 了解GDI
三. 掌握常用的绘图方法
3.1 绘制一些简单的图形
3.2 绘制一个多色的矩形
3.3 绘制一个渐变的矩形
3.4 绘制一个多色渐变的矩形
四. 应用本文学到的方法打造属于自已的第一批图形
4.1 电子屏效果
4.2 霓虹灯效果
4.3 进度条显示效果
前言
用惯了别人做的图形控件,常常感慨别人做得好,心中徒生羡慕。
何时自已也能做出变幻莫测的图形效果呢?
想想.Net 对图形支持功能非常丰富,何不自已动手打造呢?!
好了,闲话少说,开始我们打造自已的图形之旅吧.
本文的结尾提供完整源码下载.
一.认识 System.Drawing类
Code
private void drawGraphicsPath()
{
Graphics g = this.pictureBox7.CreateGraphics();
g.Clear(this.pictureBox7.BackColor );
//消除锯齿
g.SmoothingMode = SmoothingMode.AntiAlias;
//高质量,低速度绘制
g.CompositingQuality = CompositingQuality.HighQuality;
StringFormat mySF = new StringFormat();
mySF.Alignment = StringAlignment.Near;
mySF.LineAlignment = StringAlignment.Center;
mySF.FormatFlags = StringFormatFlags.NoWrap;
SizeF strSize = g.MeasureString(PercentStr, PercFont, new PointF(), mySF);
int strWidth = (int)(strSize.Width + 10);
GraphicsPath myPath = new GraphicsPath();
int fontStyle = (int)FontStyle.Bold;
int x = (int)((this.pictureBox7.Width - strWidth) / 2);
int y = (int)((this.pictureBox7.Height - strSize.Height) / 2);
Point origin = new Point(x, y + 5);
StringFormat format = StringFormat.GenericDefault;
// Add the string to the path.
myPath.AddString(PercentStr,
family2,
fontStyle,
emSize2,
origin,
format);
GraphicsPath stringPath = myPath;
CurrentX += this.pictureBox7.Width / 10;
Rectangle blotoutRect = new Rectangle(0, 0, CurrentX, this.pictureBox7.Height);
myPath.AddRectangle(blotoutRect);
//Draw the path to the screen.
g.FillPath(Brushes.Green, myPath);
}
本文源程序下载:
打造属于自已的图形(一) 源码
打造透明的可移动的图形窗体 源码
本文内容:
一. 认识 System.Drawing类
二 了解GDI
三. 掌握常用的绘图方法
3.1 绘制一些简单的图形
3.2 绘制一个多色的矩形
3.3 绘制一个渐变的矩形
3.4 绘制一个多色渐变的矩形
四. 应用本文学到的方法打造属于自已的第一批图形
4.1 电子屏效果
4.2 霓虹灯效果
4.3 进度条显示效果
前言
用惯了别人做的图形控件,常常感慨别人做得好,心中徒生羡慕。
何时自已也能做出变幻莫测的图形效果呢?
想想.Net 对图形支持功能非常丰富,何不自已动手打造呢?!
好了,闲话少说,开始我们打造自已的图形之旅吧.
本文的结尾提供完整源码下载.
一.认识 System.Drawing类
Code
private void drawGraphicsPath()
{
Graphics g = this.pictureBox7.CreateGraphics();
g.Clear(this.pictureBox7.BackColor );
//消除锯齿
g.SmoothingMode = SmoothingMode.AntiAlias;
//高质量,低速度绘制
g.CompositingQuality = CompositingQuality.HighQuality;
StringFormat mySF = new StringFormat();
mySF.Alignment = StringAlignment.Near;
mySF.LineAlignment = StringAlignment.Center;
mySF.FormatFlags = StringFormatFlags.NoWrap;
SizeF strSize = g.MeasureString(PercentStr, PercFont, new PointF(), mySF);
int strWidth = (int)(strSize.Width + 10);
GraphicsPath myPath = new GraphicsPath();
int fontStyle = (int)FontStyle.Bold;
int x = (int)((this.pictureBox7.Width - strWidth) / 2);
int y = (int)((this.pictureBox7.Height - strSize.Height) / 2);
Point origin = new Point(x, y + 5);
StringFormat format = StringFormat.GenericDefault;
// Add the string to the path.
myPath.AddString(PercentStr,
family2,
fontStyle,
emSize2,
origin,
format);
GraphicsPath stringPath = myPath;
CurrentX += this.pictureBox7.Width / 10;
Rectangle blotoutRect = new Rectangle(0, 0, CurrentX, this.pictureBox7.Height);
myPath.AddRectangle(blotoutRect);
//Draw the path to the screen.
g.FillPath(Brushes.Green, myPath);
}
本文源程序下载:
打造属于自已的图形(一) 源码
打造透明的可移动的图形窗体 源码
相关文章推荐
- HTML5绘图基础_08_绘制多个图形(七巧板)
- Golang 绘图基础 -绘制简单图形
- JAVA基础8.1——绘图基础(1)绘制图形
- HTML5绘图基础_07_绘制第二个图形
- flash 绘图API:绘制基础的图形
- GDI+图形图像处理技术——GDIPlus绘图基础
- 自定义View之绘图篇(一):基础图形的绘制
- flash 绘图API:绘制基础的图形
- Android零基础入门第13节:Android Studio配置优化,打造开发利器
- 第五章 图形基础part1
- Android基础入门教程——8.3.1 三个绘图工具类详解
- C#学习之GDI + 图形编程基础(二)
- Android的图形与图像处理之一 使用简单图片&绘图
- 打造以价值观为基础的高效团队
- WindowsAPI学习笔记二 - 图形设备接口及windows绘图
- 《Android内核剖析》读书笔记 第12章 屏幕绘图基础
- 更新 第五章 绘图基础(设备环境)
- 3D数学基础:图形与游戏开发 第3章笔记
- 图形与游戏中3D数学基础的说明
- Java — 图形程序设计基础