コード例 #1
0
		/// <summary>
		/// 向拼图碎片的路径中添加一条边,路径的当前节点总是在起始点。
		/// </summary>
		/// <param name="path">路径。</param>
		/// <param name="startPoint">边的起始点。</param>
		/// <param name="endPoint">边的结束点。</param>
		/// <param name="randoms">该边的凹凸性。</param>
		/// <param name="border">与该条边相关的一组随机数,范围都是 [0, 1)。</param>
		protected override void AddBorder(Path path, Vector2 startPoint, Vector2 endPoint, bool border, float[] randoms)
		{
			// 贝塞尔曲线的起始和结束点。
			float rate1 = 1f / 3 + randoms[0] / 12;
			Vector2 sp = Vector2.Lerp(startPoint, endPoint, rate1);
			Vector2 ep = Vector2.Lerp(startPoint, endPoint, 1 - rate1);
			// 贝塞尔曲线的控制点。
			float rate2 = rate1 - randoms[1] / 4;
			Vector2 c1 = Vector2.Lerp(startPoint, endPoint, rate2);
			Vector2 c2 = Vector2.Lerp(startPoint, endPoint, 1 - rate2);
			// 与边框垂直的向量。
			Vector2 cross = new Vector2(endPoint.Y - startPoint.Y, startPoint.X - endPoint.X);
			if (!border)
			{
				cross.X *= -1;
				cross.Y *= -1;
			}
			cross *= 1f / 4 + randoms[2] / 8;
			c1 += cross;
			c2 += cross;
			// 连接边框的贝塞尔曲线。
			float rate3 = 1f / 6 + randoms[3] / 6;
			Vector2 sc2 = sp + (sp - c1) * rate3;
			Vector2 sc1 = Vector2.Lerp(startPoint, sc2, randoms[4]);
			Vector2 ec1 = ep + (ep - c2) * rate3;
			Vector2 ec2 = Vector2.Lerp(endPoint, ec1, randoms[4]);
			path.AddBezier(sp, sc1, sc2);
			path.AddBezier(ep, c1, c2);
			path.AddBezier(endPoint, ec1, ec2);
		}
コード例 #2
0
 public override void AddBezier(IPoint2F p1,
                                IPoint2F p2,
                                IPoint2F p3,
                                IPoint2F p4)
 {
     Path.AddBezier(Pf(p1), Pf(p2), Pf(p3), Pf(p4));
 }
コード例 #3
0
 public override void AddBezier(Single x1,
                                Single y1,
                                Single x2,
                                Single y2,
                                Single x3,
                                Single y3,
                                Single x4,
                                Single y4)
 {
     Path.AddBezier(x1, y1, x2, y2, x3, y3, x4, y4);
 }
コード例 #4
0
 private void LCPath()
 {
     WidthF  = 6.02F;
     HeightF = 6.02F;
     Path.StartFigure();
     Path.AddLines(new PointF[] { new PointF(-2.2F * Scale * _pixelToMmMultiple, -1.9F * -1 * Scale * _pixelToMmMultiple), new PointF(-2.2F * Scale * _pixelToMmMultiple, 1.9F * -1 * Scale * _pixelToMmMultiple) });
     Path.AddBezier(-2.2F * Scale * _pixelToMmMultiple, 1.9F * -1 * Scale * _pixelToMmMultiple, -2.2F * Scale * _pixelToMmMultiple, 2.2F * -1 * Scale * _pixelToMmMultiple, -1.9F * Scale * _pixelToMmMultiple, 2.2F * -1 * Scale * _pixelToMmMultiple, -1.9F * Scale * _pixelToMmMultiple, 2.2F * -1 * Scale * _pixelToMmMultiple);
     Path.AddLines(new PointF[] { new PointF(-1.59F * Scale * _pixelToMmMultiple, 2.2F * -1 * Scale * _pixelToMmMultiple), new PointF(-1.59F * Scale * _pixelToMmMultiple, 2.1F * -1 * Scale * _pixelToMmMultiple), new PointF(1.59F * Scale * _pixelToMmMultiple, 2.1F * -1 * Scale * _pixelToMmMultiple), new PointF(1.59F * Scale * _pixelToMmMultiple, 2.2F * -1 * Scale * _pixelToMmMultiple) });
     Path.AddBezier(1.9F * Scale * _pixelToMmMultiple, 2.2F * -1 * Scale * _pixelToMmMultiple, 1.9F * Scale * _pixelToMmMultiple, 2.2F * -1 * Scale * _pixelToMmMultiple, 2.2F * Scale * _pixelToMmMultiple, 2.2F * -1 * Scale * _pixelToMmMultiple, 2.2F * Scale * _pixelToMmMultiple, 1.9F * -1 * Scale * _pixelToMmMultiple);
     Path.AddLines(new PointF[] { new PointF(2.2F * Scale * _pixelToMmMultiple, 1.9F * -1 * Scale * _pixelToMmMultiple), new PointF(2.2F * Scale * _pixelToMmMultiple, -1.9F * -1 * Scale * _pixelToMmMultiple) });
     Path.AddBezier(2.2F * Scale * _pixelToMmMultiple, -1.9F * -1 * Scale * _pixelToMmMultiple, 2.2F * Scale * _pixelToMmMultiple, -1.9F * -1 * Scale * _pixelToMmMultiple, 2.2F * Scale * _pixelToMmMultiple, -2.2F * -1 * Scale * _pixelToMmMultiple, 1.9F * Scale * _pixelToMmMultiple, -2.2F * -1 * Scale * _pixelToMmMultiple);
     Path.AddLines(new PointF[] { new PointF(1.9F * Scale * _pixelToMmMultiple, -2.2F * -1 * Scale * _pixelToMmMultiple), new PointF(-1.9F * Scale * _pixelToMmMultiple, -2.2F * -1 * Scale * _pixelToMmMultiple) });
     Path.AddBezier(-1.9F * Scale * _pixelToMmMultiple, -2.2F * -1 * Scale * _pixelToMmMultiple, -1.9F * Scale * _pixelToMmMultiple, -2.2F * -1 * Scale * _pixelToMmMultiple, -2.2F * Scale * _pixelToMmMultiple, -2.2F * -1 * Scale * _pixelToMmMultiple, -2.2F * Scale * _pixelToMmMultiple, -1.9F * -1 * Scale * _pixelToMmMultiple);
     Path.CloseFigure();
     Path.StartFigure();
     Path.AddLines(new PointF[] { new PointF(-2.1F * Scale * _pixelToMmMultiple, -1.8F * -1 * Scale * _pixelToMmMultiple) });
     Path.AddBezier(-2.1F * Scale * _pixelToMmMultiple, 1.8F * -1 * Scale * _pixelToMmMultiple, -2.1F * Scale * _pixelToMmMultiple, 2.1F * -1 * Scale * _pixelToMmMultiple, -1.8F * Scale * _pixelToMmMultiple, 2.1F * -1 * Scale * _pixelToMmMultiple, -1.8F * Scale * _pixelToMmMultiple, 2.1F * -1 * Scale * _pixelToMmMultiple);
     Path.AddLines(new PointF[] { new PointF(-1.8F * Scale * _pixelToMmMultiple, 2.1F * -1 * Scale * _pixelToMmMultiple), new PointF(1.8F * Scale * _pixelToMmMultiple, 2.1F * -1 * Scale * _pixelToMmMultiple) });
     Path.AddBezier(1.8F * Scale * _pixelToMmMultiple, 2.1F * -1 * Scale * _pixelToMmMultiple, 2.1F * Scale * _pixelToMmMultiple, 2.1F * -1 * Scale * _pixelToMmMultiple, 2.1F * Scale * _pixelToMmMultiple, 1.8F * -1 * Scale * _pixelToMmMultiple, 2.1F * Scale * _pixelToMmMultiple, 1.8F * -1 * Scale * _pixelToMmMultiple);
     Path.AddLines(new PointF[] { new PointF(2.1F * Scale * _pixelToMmMultiple, 1.2F * -1 * Scale * _pixelToMmMultiple), new PointF(2.1F * Scale * _pixelToMmMultiple, -1.2F * -1 * Scale * _pixelToMmMultiple) });
     Path.AddBezier(2.1F * Scale * _pixelToMmMultiple, -1.8F * -1 * Scale * _pixelToMmMultiple, 2.1F * Scale * _pixelToMmMultiple, -1.8F * -1 * Scale * _pixelToMmMultiple, 2.1F * Scale * _pixelToMmMultiple, -2.1F * -1 * Scale * _pixelToMmMultiple, 1.8F * Scale * _pixelToMmMultiple, -2.1F * -1 * Scale * _pixelToMmMultiple);
     Path.AddLines(new PointF[] { new PointF(1.8F * Scale * _pixelToMmMultiple, -2.1F * -1 * Scale * _pixelToMmMultiple), new PointF(-1.8F * Scale * _pixelToMmMultiple, -2.1F * -1 * Scale * _pixelToMmMultiple) });
     Path.AddBezier(-1.8F * Scale * _pixelToMmMultiple, -2.1F * -1 * Scale * _pixelToMmMultiple, -2.1F * Scale * _pixelToMmMultiple, -2.1F * -1 * Scale * _pixelToMmMultiple, -2.1F * Scale * _pixelToMmMultiple, -1.8F * -1 * Scale * _pixelToMmMultiple, -2.1F * Scale * _pixelToMmMultiple, -1.8F * -1 * Scale * _pixelToMmMultiple);
     Path.CloseFigure();
     Path.StartFigure();
     Path.AddRectangle(new RectangleF(-1.6F * Scale * _pixelToMmMultiple, 2.39F * -1 * Scale * _pixelToMmMultiple, 3.2F * Scale * _pixelToMmMultiple, 0.29F * Scale * _pixelToMmMultiple));
     Path.CloseFigure();
     Path.StartFigure();
     Path.AddRectangle(new RectangleF(-1.6F * Scale * _pixelToMmMultiple, 2.59F * -1 * Scale * _pixelToMmMultiple, 3.2F * Scale * _pixelToMmMultiple, 0.2F * Scale * _pixelToMmMultiple));
     Path.CloseFigure();
     Path.StartFigure();
     Path.AddArc(-0.625F * Scale * _pixelToMmMultiple, 0.625F * -1 * Scale * _pixelToMmMultiple, 1.25F * Scale * _pixelToMmMultiple, 1.25F * Scale * _pixelToMmMultiple, 180F, 360F);
     Path.CloseFigure();
     Path.StartFigure();
     Path.AddArc(-0.3F * Scale * _pixelToMmMultiple, 0.3F * -1 * Scale * _pixelToMmMultiple, 0.6F * Scale * _pixelToMmMultiple, 0.6F * Scale * _pixelToMmMultiple, 180F, 360F);
     Path.CloseFigure();
     Path.StartFigure();
     Path.AddArc(-1.5F * Scale * _pixelToMmMultiple, 1.5F * -1 * Scale * _pixelToMmMultiple, 3F * Scale * _pixelToMmMultiple, 3F * Scale * _pixelToMmMultiple, 180F, 360F);
     Path.CloseFigure();
 }
コード例 #5
0
		/// <summary>
		/// 向拼图碎片的路径中添加一条边,路径的当前节点总是在起始点。
		/// </summary>
		/// <param name="path">路径。</param>
		/// <param name="startPoint">边的起始点。</param>
		/// <param name="endPoint">边的结束点。</param>
		/// <param name="randoms">该边的凹凸性。</param>
		/// <param name="border">与该条边相关的一组随机数,范围都是 [0, 1)。</param>
		protected override void AddBorder(Path path, Vector2 startPoint, Vector2 endPoint,
			bool border, float[] randoms)
		{
			// 贝塞尔曲线的起始和结束点。
			float rate1 = 1f / 3 + randoms[0] / 12;
			Vector2 sp = Vector2.Lerp(startPoint, endPoint, rate1);
			Vector2 ep = Vector2.Lerp(startPoint, endPoint, 1 - rate1);
			// 贝塞尔曲线的控制点。
			float rate2 = rate1 - randoms[1] / 4;
			Vector2 c1 = Vector2.Lerp(startPoint, endPoint, rate2);
			Vector2 c2 = Vector2.Lerp(startPoint, endPoint, 1 - rate2);
			// 与边框垂直的向量。
			Vector2 cross = new Vector2(endPoint.Y - startPoint.Y, startPoint.X - endPoint.X);
			if (!border)
			{
				cross.X *= -1;
				cross.Y *= -1;
			}
			cross *= 1f / 4 + randoms[2] / 8;
			path.AddLine(sp);
			path.AddBezier(ep, c1 + cross, c2 + cross);
			path.AddLine(endPoint);
		}
コード例 #6
0
 public void AddBezier(Point startPoint, Point controlPoint1, Point controlPoint2, Point endPoint)
 {
     Path.AddBezier(startPoint, controlPoint1, controlPoint2, endPoint);
 }
コード例 #7
0
 public void BezierTo(float x1, float y1, float x2, float y2, float x3, float y3)
 {
     Path.AddBezier(X, Y, x1, y1, x2, y2, x3, y3);
     MoveTo(x3, y3);
 }