AnnotateInvalidAreaHelper.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. using QuestPDF.Helpers;
  2. using SkiaSharp;
  3. namespace QuestPDF.LayoutTests.TestEngine;
  4. internal static class AnnotateInvalidAreaHelper
  5. {
  6. private const float StripeThickness = 1f;
  7. private const float StripeScale = 3f;
  8. private static readonly Color LineColor = Colors.Red.Medium;
  9. public static void Annotate(SKCanvas canvas, SKPath area)
  10. {
  11. canvas.Save();
  12. canvas.ClipPath(area);
  13. DrawCheckerboardPattern();
  14. canvas.Restore();
  15. void DrawCheckerboardPattern()
  16. {
  17. var matrix = SKMatrix.CreateScale(StripeScale, StripeScale).PostConcat(SKMatrix.CreateRotation((float)(Math.PI / 4)));
  18. using var paint = new SKPaint
  19. {
  20. Color = new SKColor(LineColor),
  21. PathEffect = SKPathEffect.Create2DLine(StripeThickness, matrix),
  22. IsAntialias = true
  23. };
  24. var stripeArea = area.Bounds;
  25. stripeArea.Inflate(StripeScale * 2, StripeScale * 2);
  26. canvas.DrawRect(stripeArea, paint);
  27. }
  28. }
  29. }