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

Reading number is top 10 articles
WEB开发者需要了解的IE7的新功能_[Html教程]
如何在C#中播放AVI短片并使背景透明_[Asp.Net教程]
DataGrid单击一行服务器事件_[Asp.Net教程]
.NET2.0DataList分页_[Asp.Net教程]
ASP.NET安装完全手册_[Asp.Net教程]
ASP.NET,2.0高级数据处理之主从数据表_.net资料_编程技术
sql server日志文件总结及日志满的处理办法_[SQL Server教程]
C#网络应用编程基础练习题与答案(八)_[Asp.Net教程]
Asp.Net,XML操作基类_[Asp.Net教程]
ASP.NET,2.0中的Web和HTML服务器控件_[Asp.Net教程]
Reading number is top 10 pictures
移民小国也实惠2
美女
From China fortress sora aoi3
In the world the most mysterious 21 place landscape3
Men don't mature ten sign
Magnificent cloud2
性感丰满身材火爆de美女1
The real super beauty13
Lewd,it is too lewd.
不知名的美女素颜照1
Download software ranking
Tram sex maniac 2 (H) rar bag9
双旗镇刀客A
Unix video tutorial18
The Bermuda triangle2
虚拟机汉化软件
WebService在.NET中的实战应用教学视频 → 第2集
网络管理员第三版
尖东毒玫瑰B
双旗镇刀客B
jBuilder2006
qq published in(发表于) 2014/7/11 9:16:37 Edit(编辑)
c#中GDI+图形图像:GDI+中的基数样条使用方法

c#中GDI+图形图像:GDI+中的基数样条使用方法

c#中GDI+图形图像:GDI+中的基数样条使用方法|实例

GDI+中的基数样条

基数样条是一连串单独的曲线,这些曲线连接起来形成一条较大的曲线。基数样条由点的数组和张力参数指定,样条平滑地经过数组中的每个点,曲线的陡度上没有尖角和突然的变化。

绘制基数样条,需要Graphics对象、Pen对象和Point(或PointF)对象数组。Graphics 类的实例提供了DrawCurve方法用于绘制基数样条,Pen对象存储基数样条的属性(如线宽和颜色等),Point(或PointF)对象数组存储曲线将要经过的点。DrawCurve方法为可重载方法,其常用格式有以下4种。

(1)绘制经过一组指定Point结构的基数样条。

语法:

public void DrawCurve (

Pen pen,

Point[] points)

参数说明如下。

pen:Pen对象,它确定曲线的颜色、宽度和高度。

points:Point结构数组,这些结构定义样条。

(2)使用指定的张力,绘制经过一组指定Point结构的基数样条。

语法:

public void DrawCurve (

Pen pen,

Point[] points,

float tension)

参数说明如下。

pen:Pen对象,它确定曲线的颜色、宽度和高度。

points:Point结构数组,这些结构定义样条。

tension:大于或等于0.0F的值,该值指定曲线的张力。

(3)从相对于数组开始位置的偏移量开始,绘制经过一组指定PointF结构的基数样条。

语法:

public void DrawCurve (

Pen pen,

PointF[] points,

int offset,

int numberOfSegments)

DrawCurve方法中各参数及说明如表1所示。



表1 DrawCurve方法参数及说明

(4)使用指定的张力,绘制经过一组指定Point结构的基数样条。

语法:

public void DrawCurve (

Pen pen,

Point[] points,

Int offset,

int numberOfSegments,

float tension)

DrawCurve方法中各参数及说明如表2所示。



表2 DrawCurve方法参数及说明

示例

绘制基数样条

本示例中,当程序运行时,单击【绘制基数样条】按钮,在窗体中使用指定的张力,绘制一条经过指定Point结构的基数样条。示例运行结果如图1所示。



图1 绘制基数样条

程序代码如下。

Form1窗体中,在【绘制基数样条】按钮的Click事件中分别声明Graphics类和Pen类的两个对象,然后实例化6个Point对象,用来作为基数样条的各连接点,声明一个Point结构数组,并将已经实例化的6个Point对象赋值给该数组,最后调用Graphics对象的DrawCurve方法绘制一条经过Point结构的基数样条。【绘制基数样条】按钮的Click事件代码如下:

private void button1_Click(object sender, EventArgs e)

{

Graphics graphics = this.CreateGraphics();

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

Point point1 = new Point(50, 20);

Point point2 = new Point(60, 30);

Point point3 = new Point(70, 25);

Point point4 = new Point(100, 50);

Point point5 = new Point(130, 30);

Point point6 = new Point(150, 45);

Point[] myPoints = { point1, point2, point3, point4, point5, point6 };

graphics.DrawCurve(myPen, myPoints, 1.0F);

}

完整程序代码如下:

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

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

namespace _6_06

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

Graphics graphics = this.CreateGraphics();

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

Point point1 = new Point(50, 20);

Point point2 = new Point(60, 30);

Point point3 = new Point(70, 25);

Point point4 = new Point(100, 50);

Point point5 = new Point(130, 30);

Point point6 = new Point(150, 45);

Point[] myPoints = { point1, point2, point3, point4, point5, point6 };

graphics.DrawCurve(myPen, myPoints, 1.0F);



添加到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.