public AddCurve ( PointF points, int offset, int numberOfSegments, float tension ) : void | ||
points | PointF | |
offset | int | |
numberOfSegments | int | |
tension | float | |
Результат | void |
public void AddCurve(PointF[] points, int offset, int numberOfSegments, float tension)
{
if (points == null)
throw new ArgumentNullException ("points");
if (numberOfSegments < 1)
throw new ArgumentException ("numberOfSegments");
int count = points.Length;
// we need 3 points for the first curve, 2 more for each curves
// and it's possible to use a point prior to the offset (to calculate)
if (offset == 0 && numberOfSegments == 1 && count < 3)
throw new ArgumentException ("invalid parameters");
if (numberOfSegments >= points.Length - offset)
throw new ArgumentException ("offset");
var tangents = GeomUtilities.GetCurveTangents (CURVE_MIN_TERMS, points, count, tension, CurveType.Open);
AppendCurve (points, tangents, offset, numberOfSegments, CurveType.Open);
}
GraphicsPath::AddCurve ( Point points ) : void | |
GraphicsPath::AddCurve ( Point points, float tension ) : void | |
GraphicsPath::AddCurve ( Point points, int offset, int numberOfSegments, float tension ) : void | |
GraphicsPath::AddCurve ( PointF points ) : void | |
GraphicsPath::AddCurve ( PointF points, float tension ) : void |
private void Demo0(Graphics g) { renderXY(g);//初始化坐标轴 //========划线-画点 Pen pen1 = new Pen(Color.Red, 1); Pen pen2 = new Pen(Color.Blue); int total_point_num=1000; PointF[] CurvePoints = new PointF[total_point_num]; for (int x = 0; x < total_point_num; x += 10) { //计算点坐标-正弦曲线 float y = (float)( 100*Math.Sin(x*300) ); //坐标轴置换 y = -y + this.pictureBox1.Height-200; //点保存到数组中,供下文创建路径用 CurvePoints[x] = new PointF(x, y); //画空心点-画笔,矩形(坐标x,坐标y,宽度,高度); g.DrawEllipse(pen2, new RectangleF(x, y, 3, 3)); } //创建路径 GraphicsPath myPath = new GraphicsPath(); //AddCurve(点阵,起点,终点,弯曲程度) //myPath.AddCurve(CurvePoints, 0, 7, 0.8f); myPath.AddCurve(CurvePoints,0,300,0.01F); //定义画笔 Pen myPen = new Pen(Color.Red, 1); //划线--------------------------------------------bug为什么点稀疏的时候不是两两连接? //g.DrawPath(myPen, myPath); //g.DrawCurve(pen1, CurvePoints, 0.05F); }