AspectRatio.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. namespace FastReport.Export.Svg
  2. {
  3. /// <summary>
  4. /// Specifies the alignment methods
  5. /// </summary>
  6. public enum Align
  7. {
  8. /// <summary>
  9. /// Do not force uniform scaling. Scale the graphic content of the given element non-uniformly
  10. /// if necessary such that the element's bounding box exactly matches the viewport rectangle.
  11. /// </summary>
  12. none,
  13. /// <summary>
  14. /// Force uniform scaling. Align the min-x of the element's viewBox with the smallest X value
  15. /// of the viewport. Align the min-y of the element's viewBox with the smallest Y value of the viewport.
  16. /// </summary>
  17. xMinYMin,
  18. /// <summary>
  19. /// Force uniform scaling. Align the midpoint X value of the element's viewBox with the midpoint
  20. /// X value of the viewport. Align the min-y of the element's viewBox with the smallest Y value
  21. /// of the viewport.
  22. /// </summary>
  23. xMidYMin,
  24. /// <summary>
  25. /// Force uniform scaling. Align the min-x+width of the element's viewBox with the maximum X value
  26. /// of the viewport. Align the min-y of the element's viewBox with the smallest Y value of the viewport.
  27. /// </summary>
  28. xMaxYMin,
  29. /// <summary>
  30. /// Force uniform scaling. Align the min-x of the element's viewBox with the smallest X value of
  31. /// the viewport. Align the midpoint Y value of the element's viewBox with the midpoint Y value
  32. /// of the viewport.
  33. /// </summary>
  34. xMinYMid,
  35. /// <summary>
  36. /// The default. Force uniform scaling. Align the midpoint X value of the element's viewBox
  37. /// with the midpoint X value of the viewport. Align the midpoint Y value of the element's
  38. /// viewBox with the midpoint Y value of the viewport.
  39. /// </summary>
  40. xMidYMid,
  41. /// <summary>
  42. /// Force uniform scaling. Align the min-x+width of the element's viewBox with the maximum X
  43. /// value of the viewport. Align the midpoint Y value of the element's viewBox with the midpoint
  44. /// Y value of the viewport.
  45. /// </summary>
  46. xMaxYMid,
  47. /// <summary>
  48. /// Force uniform scaling. Align the min-x of the element's viewBox with the smallest X value of
  49. /// the viewport. Align the min-y+height of the element's viewBox with the maximum Y value of the viewport.
  50. /// </summary>
  51. xMinYMax,
  52. /// <summary>
  53. /// Force uniform scaling. Align the midpoint X value of the element's viewBox with the midpoint X
  54. /// value of the viewport. Align the min-y+height of the element's viewBox with the maximum Y value
  55. /// of the viewport.
  56. /// </summary>
  57. xMidYMax,
  58. /// <summary>
  59. /// Force uniform scaling. Align the min-x+width of the element's viewBox with the maximum X value of
  60. /// the viewport. Align the min-y+height of the element's viewBox with the maximum Y value of the viewport.
  61. /// </summary>
  62. xMaxYMax
  63. }
  64. /// <summary>
  65. /// Specifies the svg scale types
  66. /// </summary>
  67. public enum MeetOrSlice
  68. {
  69. /// <summary>
  70. /// (the default) - Scale the graphic such that:
  71. /// - aspect ratio is preserved
  72. /// - the entire viewBox is visible within the viewport
  73. /// - the viewBox is scaled up as much as possible, while still meeting the other criteria
  74. /// </summary>
  75. meet,
  76. /// <summary>
  77. /// Scale the graphic such that:
  78. /// - aspect ratio is preserved
  79. /// - the entire viewport is covered by the viewBox
  80. /// - the viewBox is scaled down as much as possible, while still meeting the other criteria
  81. /// </summary>
  82. slice
  83. }
  84. /// <summary>
  85. /// Describes scaling of a svg documents
  86. /// </summary>
  87. public class AspectRatio
  88. {
  89. private Align align;
  90. private MeetOrSlice? meetOrSlice;
  91. /// <summary>
  92. /// Gets the align value
  93. /// </summary>
  94. public Align Align { get { return align; } }
  95. /// <summary>
  96. /// Gets the meetOrSlice value
  97. /// </summary>
  98. public MeetOrSlice? MeetOrSlice { get { return meetOrSlice; } }
  99. /// <summary>
  100. /// Initializes a new instance of the <see cref="AspectRatio"/> class.
  101. /// </summary>
  102. /// <param name="align"></param>
  103. public AspectRatio(Align align)
  104. {
  105. this.align = align;
  106. }
  107. /// <summary>
  108. /// Initializes a new instance of the <see cref="AspectRatio"/> class.
  109. /// </summary>
  110. /// <param name="align">Align value</param>
  111. /// <param name="meetOrSlice">meetOrSlice value</param>
  112. public AspectRatio(Align align, MeetOrSlice meetOrSlice) : this(align)
  113. {
  114. this.meetOrSlice = meetOrSlice;
  115. }
  116. }
  117. }