mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-10-15 03:34:52 +08:00
minor corrections
This commit is contained in:
@@ -193,7 +193,7 @@
|
||||
/// <param name="points">The points.</param>
|
||||
public static PdfRectangle MinimumAreaRectangle(IEnumerable<PdfPoint> points)
|
||||
{
|
||||
if (points == null || points.Count() == 0)
|
||||
if (points?.Any() != true)
|
||||
{
|
||||
throw new ArgumentException("MinimumAreaRectangle(): points cannot be null and must contain at least one point.", nameof(points));
|
||||
}
|
||||
@@ -210,7 +210,7 @@
|
||||
{
|
||||
if (points == null || points.Count < 2)
|
||||
{
|
||||
throw new ArgumentException("OrientedBoundingBox(): points cannot be null and must contain at least two points.");
|
||||
throw new ArgumentException("OrientedBoundingBox(): points cannot be null and must contain at least two points.", nameof(points));
|
||||
}
|
||||
|
||||
// Fitting a line through the points
|
||||
@@ -252,8 +252,7 @@
|
||||
cos, sin, 0,
|
||||
-sin, cos, 0,
|
||||
0, 0, 1);
|
||||
var obb = rotateBack.Transform(aabb);
|
||||
return obb;
|
||||
return rotateBack.Transform(aabb);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -261,9 +260,9 @@
|
||||
/// </summary>
|
||||
public static IEnumerable<PdfPoint> GrahamScan(IEnumerable<PdfPoint> points)
|
||||
{
|
||||
if (points == null || points.Count() == 0)
|
||||
if (points?.Any() != true)
|
||||
{
|
||||
throw new ArgumentException("GrahamScan(): points cannot be null and must contain at least one point.");
|
||||
throw new ArgumentException("GrahamScan(): points cannot be null and must contain at least one point.", nameof(points));
|
||||
}
|
||||
|
||||
if (points.Count() < 3) return points;
|
||||
@@ -814,7 +813,7 @@
|
||||
|
||||
var solution = SolveCubicEquation(a, b, c, d);
|
||||
|
||||
return solution.Where(s => !double.IsNaN(s)).Where(s => s >= -epsilon && (s - 1) <= epsilon).OrderBy(s => s).ToArray();
|
||||
return solution.Where(s => !double.IsNaN(s) && s >= -epsilon && (s - 1) <= epsilon).OrderBy(s => s).ToArray();
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -1056,7 +1055,6 @@
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private const double OneThird = 0.333333333333333333333;
|
||||
@@ -1182,8 +1180,7 @@
|
||||
{
|
||||
string BboxToRect(PdfRectangle box, string stroke)
|
||||
{
|
||||
var overallBbox = $"<rect x='{box.Left}' y='{box.Bottom}' width='{box.Width}' height='{box.Height}' stroke-width='2' fill='none' stroke='{stroke}'></rect>";
|
||||
return overallBbox;
|
||||
return $"<rect x='{box.Left}' y='{box.Bottom}' width='{box.Width}' height='{box.Height}' stroke-width='2' fill='none' stroke='{stroke}'></rect>";
|
||||
}
|
||||
|
||||
var glyph = p.ToSvg(height);
|
||||
@@ -1202,9 +1199,7 @@
|
||||
var path = $"<path d='{glyph}' stroke='cyan' stroke-width='3'></path>";
|
||||
var bboxRect = bbox.HasValue ? BboxToRect(bbox.Value, "yellow") : string.Empty;
|
||||
var others = string.Join(" ", bboxes.Select(x => BboxToRect(x, "gray")));
|
||||
var result = $"<svg width='500' height='500'><g transform=\"scale(0.2, -0.2) translate(100, -700)\">{path} {bboxRect} {others}</g></svg>";
|
||||
|
||||
return result;
|
||||
return $"<svg width='500' height='500'><g transform=\"scale(0.2, -0.2) translate(100, -700)\">{path} {bboxRect} {others}</g></svg>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user