remove old clipping rule code and make enum byte

removes the unused set winding rule method and makes the clipping rule enum a byte which will save 3 bytes per pdfpath instance.
This commit is contained in:
Eliot Jones
2020-02-24 11:29:06 +00:00
parent 0afaa19d15
commit 7ac3fb2a39
2 changed files with 19 additions and 23 deletions

View File

@@ -3,12 +3,12 @@
/// <summary>
/// Rules for determining which points lie inside/outside a path.
/// </summary>
public enum ClippingRule
public enum ClippingRule : byte
{
/// <summary>
/// No rule.
/// </summary>
None,
None = 0,
/// <summary>
/// This even-odd rule determines whether a point is inside a path by drawing a ray from that point in
@@ -17,7 +17,7 @@
/// the same results as the nonzero winding number rule for paths with simple shapes, but produces
/// different results for more complex shapes.
/// </summary>
EvenOdd,
EvenOdd = 1,
/// <summary>
/// The nonzero winding number rule determines whether a given point is inside a path by conceptually
@@ -27,6 +27,6 @@
/// to left. After counting all the crossings, if the result is 0, the point is outside the path;
/// otherwise, it is inside.
/// </summary>
NonZeroWinding
NonZeroWinding = 2
}
}

View File

@@ -36,20 +36,6 @@
private double shoeLaceSum;
/// <summary>
/// Return true if it is a closed path.
/// </summary>
/// <returns></returns>
public bool IsClosed()
{
// need to check if filled -> true if filled
if (Commands.Any(c => c is Close)) return true;
var filtered = Commands.Where(c => c is Line || c is BezierCurve).ToList();
if (filtered.Count < 2) return false;
if (!GetStartPoint(filtered.First()).Equals(GetEndPoint(filtered.Last()))) return false;
return true;
}
/// <summary>
/// Return true if points are organised in a clockwise order. Works only with closed paths.
/// </summary>
@@ -89,9 +75,8 @@
}
/// <summary>
///
/// Set the clipping mode for this path.
/// </summary>
/// <param name="clippingRule"></param>
public void SetClipping(ClippingRule clippingRule)
{
IsClipping = true;
@@ -240,9 +225,7 @@
MoveTo(x3, y3);
}
}
internal void SetWindingRuleMode(int windingRule) { }
/// <summary>
/// Close the path.
/// </summary>
@@ -258,6 +241,19 @@
}
commands.Add(new Close());
}
/// <summary>
/// Determines if the path is currently closed.
/// </summary>
public bool IsClosed()
{
// need to check if filled -> true if filled
if (Commands.Any(c => c is Close)) return true;
var filtered = Commands.Where(c => c is Line || c is BezierCurve).ToList();
if (filtered.Count < 2) return false;
if (!GetStartPoint(filtered.First()).Equals(GetEndPoint(filtered.Last()))) return false;
return true;
}
/// <summary>
/// Gets a <see cref="PdfRectangle"/> which entirely contains the geometry of the defined path.