All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
SQL语言基础(1)_mssql学习_编程技术
PHP应用技巧小总结:几个有用的小技巧_[PHP教程]
两个SQL,Server维护技巧_[SQL,Server教程]
XHTML+CSS标准网页-调用样式表_[Html教程]
浅析SQL,Server全文检索查询_mssql学习_编程技术
asp.net,取得远程的IP地址和浏览器类型_[Asp.Net教程]
Linux操作系统中用PHP构建网站详解_php资料_编程技术
让ASP.NET简便使用SCRIPT_[Asp.Net教程]
ASP.NET常用的三十三种实用代码_[Asp.Net教程]
PHP实例:一个比较完善的购物车类_[PHP教程]
Reading number is top 10 pictures
不知名的美女素颜照1
The money of more than 100 countries and regions12
王艳写真温柔如水1
采访谢楠
壮丽的云彩1
奇趣的世界记录1
In the world the most mysterious 21 place landscape2
采访美女孙菲菲
Men's and women's orgasms
Azusa Yamamoto1
Download software ranking
Unix video tutorial12
Eclipse 4.2.2 For Win64
美女写真2
Call Of Duty5
Detective task-the top secret prostitution files
ASP.NET.2.0.XML.高级编程(第3版)
XML+Web+Service开发教程
小黑猫大战两米大花蛇
Sora aoi's film--cangkong_Blue.Sky
Tram sex maniac 2 (H) rar bag19
qq published in(发表于) 2014/7/11 9:16:29 Edit(编辑)
c#中GDI+图形图像:GDI+中曲线的填充使用方法

c#中GDI+图形图像:GDI+中曲线的填充使用方法

c#中GDI+图形图像:GDI+中曲线的填充使用方法|实例

GDI+中曲线的填充

GDI+中,可以使用画笔来填充曲线,Graphics类填充曲线的方法有FillRectangle、FillEllipse、FillPie、FillPolygon、FillClosedCurve、FillPath和FillRegion。只要调用其中的任意一个方法,并使用一种指定的画笔类型作为其参数,就可以填充曲线。

示例

填充曲线

本示例中,当程序运行时,单击【填充曲线】按钮,在窗体中绘制一段图形路径,并使用指定画笔对该图形路径进行填充。示例运行结果如图1所示。



图1 填充曲线

Form1窗体中,单击【填充曲线】按钮,程序首先调用Graphics对象的FillPath方法,将要绘制的图形路径使用指定画笔填充好,然后再调用Graphics对象的DrawPath方法将图形路径绘制出来。【填充曲线】按钮的Click事件代码如下:

private void button1_Click(object sender, EventArgs e)

{

Graphics graphics = this.CreateGraphics();

SolidBrush mySolidBrush = new SolidBrush(Color.GreenYellow);

GraphicsPath myGraphicsPath = new GraphicsPath();

Pen myPen = new Pen(Color.Blue, 1);

Point[] myPoints = { new Point(15, 30), new Point(30, 40), new Point(50, 30) };

myGraphicsPath.AddArc(15, 20, 80, 50, 210, 120);

myGraphicsPath.StartFigure();

myGraphicsPath.AddCurve(myPoints);

myGraphicsPath.AddString("曲线填充", new FontFamily("华文行楷"), (int)FontStyle.Regular, 50, new PointF (20, 50), new StringFormat());

myGraphicsPath.AddPie(180, 20, 80, 50, 210, 120);

graphics.FillPath(mySolidBrush, myGraphicsPath);

graphics.DrawPath(myPen, myGraphicsPath);

}

完整程序代码如下:

★ ★★★★Form1.cs窗体代码文件完整程序代码★★★★★

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using System.Drawing.Drawing2D;

namespace _6_13

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

Graphics graphics = this.CreateGraphics();

SolidBrush mySolidBrush = new SolidBrush(Color.GreenYellow);

GraphicsPath myGraphicsPath = new GraphicsPath();

Pen myPen = new Pen(Color.Blue, 1);

Point[] myPoints = { new Point(15, 30), new Point(30, 40), new Point(50, 30) };

myGraphicsPath.AddArc(15, 20, 80, 50, 210, 120);

myGraphicsPath.StartFigure();

myGraphicsPath.AddCurve(myPoints);

myGraphicsPath.AddString("曲线填充", new FontFamily("华文行楷"), (int)FontStyle.Regular, 50, new PointF(20, 50), new StringFormat());

myGraphicsPath.AddPie(180, 20, 80, 50, 210, 120);

graphics.FillPath(mySolidBrush, myGraphicsPath);

graphics.DrawPath(myPen, myGraphicsPath);

}

}

}

★ ★★★★Form1.Designer.cs窗体设计文件完整程序代码★★★★★

namespace _6_13

{

partial class Form1

{

///



/// 必需的设计器变量。

///


private System.ComponentModel.IContainer components = null;

///

/// 清理所有正在使用的资源。

///


/// 如果应释放托管资源,为 true;否则为 false。

protected override void Dispose(bool disposing)

{

if (disposing && (components != null))

{

components.Dispose();

}

base.Dispose(disposing);

}

#region Windows 窗体设计器生成的代码

///

/// 设计器支持所需的方法 - 不要

/// 使用代码编辑器修改此方法的内容。

///


private void InitializeComponent()

{

this.button1 = new System.Windows.Forms.Button();

this.SuspendLayout();

//

// button1

//

this.button1.Location = new System.Drawing.Point(89, 104);

this.button1.Name = "button1";

this.button1.Size = new System.Drawing.Size(75, 23);

this.button1.TabIndex = 0;

this.button1.Text = "填充曲线";

this.button1.UseVisualStyleBackColor = true;

this.button1.Click += new System.EventHandler(this.button1_Click);

//

// Form1

//

this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);

this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;

this.ClientSize = new System.Drawing.Size(252, 139);


添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.