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

Reading number is top 10 articles
PHP编程技巧:看实例学正则表达式_[PHP教程]
SQL Server备份文件导入当前数据库_[SQL Server教程]
C#之委托和事件_[Asp.Net教程]
浅谈PHP开发团队管理及程序员做人问题_php资料_编程技术
PHP+MySQL扎实基本功_[PHP教程]
用Visual,C#实现文件下载_[Asp.Net教程]
GridView,的各种用法(4)_[Asp.Net教程]
asp.net2.0中使用session进行用户登录验证
动态网页PHP编程中八种常见的文件操作方式_[PHP教程]
解决:操作必须使用一个可更新的查询_[Asp.Net教程]
Reading number is top 10 pictures
Absolutely shocked. National geographic 50 animal photographys9
The other a successor of sora aoi
XuRe xuan cool and refreshing photoes2
你的钱干净吗?
Fury xp desktop theme
Fan bingbing black wings for platform and DanLuoWang believes beauty2
Photographed the passion of the clients and prostitutes in the sex trade picture2
Average female college students2
Go to the national museum3
Chinese paper-cut grilles art appreciation1
Download software ranking
Take off clothes to survival
Adobe Flash Player(IE) 10.0.32.18 浏览器专用的FLASH插件
仙剑奇侠传98版歌曲
Unix video tutorial11
美女写真1
Unix video tutorial4
Tram sex maniac 2 (H) rar bag3
Tram sex maniac 2 (H) rar bag15
White deer villiage
Boxer Classic video2
qq published in(发表于) 2014/7/11 9:16:50 Edit(编辑)
c#中GDI+图形图像:GDI+中的贝塞尔样条使用方法

c#中GDI+图形图像:GDI+中的贝塞尔样条使用方法

c#中GDI+图形图像:GDI+中的贝塞尔样条使用方法

GDI+中的贝塞尔样条

贝塞尔样条是由4个点指定的曲线:两个端点(p1和p2)和两个控制点(c1和c2)。曲线开始于p1,结束于p2。该曲线不经过控制点,但是控制点的作用像磁铁一样,在某些方向上拉伸曲线并影响曲线弯曲的方式。

绘制贝塞尔样条时,可以调用Graphics类中的DrawBezier方法,该方法为可重载方法,它主要用来绘制贝塞尔样条,其常用格式有以下两种。

(1)绘制由4个Point结构定义的贝塞尔样条。

语法:

public void DrawBezier (

Pen pen,

Point pt1,

Point pt2,

Point pt3,

Point pt4)

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



表1 DrawBezier方法参数及说明

(2)绘制由4个表示点的有序坐标对定义的贝塞尔样条。

语法:

public void DrawBezier (

Pen pen,

float x1,

float y1,

float x2,

float y2,

float x3,

float y3,

float x4,

float y4)

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



表2 DrawBezier方法参数及说明

示例

绘制贝塞尔样条

本示例中,当程序运行时,单击【绘制贝塞尔样条】按钮,在窗体中的指定位置绘制一段贝塞尔样条。示例运行结果如图1所示。



图1 绘制贝塞尔样条

Form1窗体中,在【绘制贝塞尔样条】按钮的Click事件中分别声明Graphics类和Pen类的两个实例对象,然后定义6个float类型的变量,分别用来表示贝塞尔样条起始点的x坐标、y坐标,第一个控制点的x坐标、y坐标,第二个点的x坐标、y坐标,结束点的x坐标和y坐标,最后调用Graphics对象的DrawBezier方法在窗体中绘制贝塞尔样条。【绘制贝塞尔样条】按钮的Click事件代码如下:

private void button1_Click(object sender, EventArgs e)

{

Graphics graphics = this.CreateGraphics();

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

float startX = 50.0F;

float startY = 80.0F;

float controlX1 = 150.0F;

float controlY1 = 20.0F;

float controlX2 = 230.0F;

float controlY2 = 50.0F;

float endX = 190.0F;

float endY = 80.0F;

graphics.DrawBezier(myPen, startX, startY, controlX1, controlY1, controlX2, controlY2, endX, endY);

}

完整程序代码如下:

★ ★★★★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_07

{

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);

float startX = 50.0F;

float startY = 80.0F;

float controlX1 = 150.0F;

float controlY1 = 20.0F;

float controlX2 = 230.0F;

float controlY2 = 50.0F;

float endX = 190.0F;

float endY = 80.0F;

graphics.DrawBezier(myPen, startX, startY, controlX1, controlY1, controlX2, controlY2, endX, endY);

}

}

}

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

namespace _6_07

{

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 窗体设计器生成的代码

///

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

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


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