BoxShadowStyle.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System;
  2. using QuestPDF.Helpers;
  3. namespace QuestPDF.Infrastructure;
  4. /// <summary>
  5. /// Represents the visual styling properties for a box shadow effect.
  6. /// </summary>
  7. public sealed class BoxShadowStyle
  8. {
  9. /// <summary>
  10. /// Gets or sets the horizontal offset of the shadow in pixels.
  11. /// Positive values move the shadow to the right, negative values move it to the left.
  12. /// </summary>
  13. public float OffsetX { get; set; }
  14. /// <summary>
  15. /// Gets or sets the vertical offset of the shadow in pixels.
  16. /// Positive values move the shadow downward, negative values move it upward.
  17. /// </summary>
  18. public float OffsetY { get; set; }
  19. /// <summary>
  20. /// Gets or sets the spread radius of the shadow in pixels.
  21. /// Positive values cause the shadow to expand, negative values cause it to contract.
  22. /// </summary>
  23. public float Spread { get; set; }
  24. /// <summary>
  25. /// Gets or sets the blur radius of the shadow in pixels.
  26. /// Higher values produce a more diffused shadow with softer edges.
  27. /// A value of 0 results in a sharp, unblurred shadow.
  28. /// </summary>
  29. /// <remarks>
  30. /// Values different from 0 may significantly impact performance and enlarge the output file size.
  31. /// Use with caution, especially in large documents or when rendering complex shadows.
  32. /// </remarks>
  33. public float Blur { get; set; }
  34. /// <summary>
  35. /// Gets or sets the color of the shadow.
  36. /// </summary>
  37. public Color Color { get; set; } = Colors.Grey.Medium;
  38. internal void Validate()
  39. {
  40. if (Blur < 0)
  41. throw new ArgumentException("Shadow blur radius cannot be negative.");
  42. }
  43. }