public ArrowEnterExit fromLeftAtYWithEdgeAtIndex(float y, int index, out Vector2f intersectionPoint) { Vector2f v = pathPoints[index]; Vector2f vNext = nextPoint(index); Edge2f edge = new Edge2f(v, vNext); bool intersects = edge.intersectionPointWithY(y, out intersectionPoint); if (!intersects) { intersectionPoint = Vector2f.Zero; return(ArrowEnterExit.DoesntIntersect); } if (vNext.y > v.y == isClockwiseOrdered) { return(ArrowEnterExit.Enters); } return(ArrowEnterExit.Exits); }
IEnumerable <PenDrawingPath> crosshatches(StripedPath stripedPath) { Matrix2f inverseRotation; PathData pdata; for (var stripeField = stripedPath.stripeField; stripeField != null; stripeField = stripeField.next) { inverseRotation = stripeField.rotation.Inverse(); if (dbugSettings.dontRotateBackFinalPenPaths) { inverseRotation = Matrix2f.Identity; } pdata = new PathData(SvgParser.SvgPath.RotatedClone(stripedPath.path, stripeField.rotation), _svgFileData.isYAxisInverted); int lastEnterEdgeIndex = -100; foreach (int i in pdata.enterFromLeftEdgeIndices) { Vector2f edgeLower = pdata.areEnterLeftEdgesPosDelta ? pdata[i] : pdata.nextPoint(i); Vector2f edgeUpper = pdata.areEnterLeftEdgesPosDelta ? pdata.nextPoint(i) : pdata[i]; Assert.IsTrue(edgeLower.y < edgeUpper.y, "something wrong at index: " + i); Edge2f leftEdge = new Edge2f(edgeLower, edgeUpper); Vector2f leftIntersection; // foreach y: find exit edges that span the y, find closest intersecion point float y = stripeField.nextStripeYPosAbove(edgeLower.y); for (; y < stripeField.nextStripeYPosAbove(edgeUpper.y); y += stripeField.interval) { if (!leftEdge.intersectionPointWithY(y, out leftIntersection)) { continue; //break; // want? } float closestXDelta = float.MaxValue; for (int j = 0; j < pdata.exitFromLeftEdgeIndices.Count; ++j) { int jV = pdata.exitFromLeftEdgeIndices[j]; Edge2f jEdge = pdata.edgeAt(jV); Vector2f intrsection; if (jEdge.intersectionPointWithY(y, out intrsection)) { float dif = intrsection.x - leftIntersection.x; if (dif > 0f && dif < closestXDelta) { closestXDelta = dif; } } } if (closestXDelta < float.MaxValue) { PenDrawingPath penPath = new PenDrawingPath(); penPath.addDownUpDrawMove( (inverseRotation * leftIntersection) * viewBoxToPaperScale, (inverseRotation * new Vector2f(leftIntersection.x + closestXDelta, y)) * viewBoxToPaperScale, Color.black); yield return(penPath); } } lastEnterEdgeIndex = i; } } }