private UIBezierPath[] SplitPath(LiquittableCircle circle, LiquittableCircle other, nfloat ratio) { var p1p2 = CircleConnectedPoint(circle, other, CoreGraphicsExtensions.DegToRad(60)); var p3p4 = CircleConnectedPoint(other, circle, CoreGraphicsExtensions.DegToRad(60)); var p1 = p1p2.Item1; var p2 = p1p2.Item2; var p3 = p3p4.Item1; var p4 = p3p4.Item2; var crossed = CoreGraphicsExtensions.Intersection(p1, p3, p2, p4); if (crossed != null) { var d1 = CircleConnectedPoint(circle, other, 0).Item1; var d2 = CircleConnectedPoint(other, circle, 0).Item1; var r = (ratio - connectThresh) / (AngleThreshold - connectThresh); var a1 = d2.Split(crossed.Value, r * r); var part = new UIBezierPath(); part.MoveTo(p1); part.AddQuadCurveToPoint(p2, a1); part.ClosePath(); var a2 = d1.Split(crossed.Value, r * r); var part2 = new UIBezierPath(); part2.MoveTo(p3); part2.AddQuadCurveToPoint(p4, a2); part2.ClosePath(); return(new[] { part, part2 }); } return(new UIBezierPath[0]); }
private UIBezierPath NormalPath(LiquittableCircle circle, LiquittableCircle other) { var p1p2 = CircleConnectedPoint(circle, other); var p3p4 = CircleConnectedPoint(other, circle); var p1 = p1p2.Item1; var p2 = p1p2.Item2; var p3 = p3p4.Item1; var p4 = p3p4.Item2; var crossed = CoreGraphicsExtensions.Intersection(p1, p3, p2, p4); if (crossed != null) { var path = new UIBezierPath(); var r = CircleRatio(circle, other); path.MoveTo(p1); var r1 = p2.Mid(p3); var r2 = p1.Mid(p4); var rate = (1 - r) / (1 - AngleThreshold) * Viscosity; var mul = r1.Mid(crossed.Value).Split(r2, rate); var mul2 = r2.Mid(crossed.Value).Split(r1, rate); path.AddQuadCurveToPoint(p4, mul); path.AddLineTo(p3); path.AddQuadCurveToPoint(p2, mul2); path.ClosePath(); return(path); } return(null); }
private UIBezierPath PathPlus(nfloat rotation) { var radius = Frame.Width * internalRadiusRatio * 0.5f; var center = Center.Minus(Frame.Location); var points = new[] { CoreGraphicsExtensions.CirclePoint(center, radius, CoreGraphicsExtensions.PI2 * 0f + rotation), CoreGraphicsExtensions.CirclePoint(center, radius, CoreGraphicsExtensions.PI2 * 1f + rotation), CoreGraphicsExtensions.CirclePoint(center, radius, CoreGraphicsExtensions.PI2 * 2f + rotation), CoreGraphicsExtensions.CirclePoint(center, radius, CoreGraphicsExtensions.PI2 * 3f + rotation) }; var path = new UIBezierPath(); path.MoveTo(points[0]); path.AddLineTo(points[2]); path.MoveTo(points[1]); path.AddLineTo(points[3]); return(path); }