UniWebViewTransform.cs 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. //
  2. // UniWebViewTransform.cs
  3. // Created by Wang Wei(@onevcat) on 2025-03-17.
  4. //
  5. // This file is a part of UniWebView Project (https://uniwebview.com)
  6. // By purchasing the asset, you are allowed to use this code in as many as projects
  7. // you want, only if you publish the final products under the name of the same account
  8. // used for the purchase.
  9. //
  10. // This asset and all corresponding files (such as source code) are provided on an
  11. // “as is” basis, without warranty of any kind, express of implied, including but not
  12. // limited to the warranties of merchantability, fitness for a particular purpose, and
  13. // noninfringement. In no event shall the authors or copyright holders be liable for any
  14. // claim, damages or other liability, whether in action of contract, tort or otherwise,
  15. // arising from, out of or in connection with the software or the use of other dealing in the software.
  16. //
  17. /// <summary>
  18. /// Represents a transformation that can be applied to a UniWebView, including rotation and scaling.
  19. ///
  20. /// The transformation includes:
  21. ///
  22. /// - **Rotation**: The angle (in degrees) by which the web view should be rotated. Positive values rotate the web
  23. /// view clockwise, while negative values rotate it counterclockwise.
  24. /// - **Scaling**: The scale factors for the X and Y axes. A scale factor of 1.0 means no scaling, while values
  25. /// greater than 1.0 enlarge the web view and values less than 1.0 shrink it.
  26. ///
  27. /// This transformation is typically used in conjunction with the `SetTransform` method in `UniWebView` to apply visual
  28. /// transformations to the web view.
  29. /// </summary>
  30. public class UniWebViewTransform {
  31. /// <summary>
  32. /// The rotation of the web view in degrees.
  33. /// </summary>
  34. public float Rotation { get; set; }
  35. /// <summary>
  36. /// The scaling factor applied to the X-axis of the web view.
  37. /// </summary>
  38. public float ScaleX { get; set; }
  39. /// <summary>
  40. /// The scaling factor applied to the Y-axis of the web view.
  41. /// </summary>
  42. public float ScaleY { get; set; }
  43. /// <summary>
  44. /// Initializes a new instance of the <see cref="UniWebViewTransform"/> class with the specified rotation and
  45. /// scaling factors.
  46. /// </summary>
  47. /// <param name="rotation">The rotation of the web view in degrees.</param>
  48. /// <param name="scaleX">The scaling factor applied to the X-axis of the web view. Default is 1.0.</param>
  49. /// <param name="scaleY">The scaling factor applied to the Y-axis of the web view. Default is 1.0.</param>
  50. public UniWebViewTransform(float rotation, float scaleX = 1.0f, float scaleY = 1.0f) {
  51. Rotation = rotation;
  52. ScaleX = scaleX;
  53. ScaleY = scaleY;
  54. }
  55. /// <summary>
  56. /// Initializes a new instance of the <see cref="UniWebViewTransform"/> class with the specified scaling factors.
  57. /// </summary>
  58. /// <param name="scaleX">The scaling factor applied to the X-axis of the web view. Default is 1.0.</param>
  59. /// <param name="scaleY">The scaling factor applied to the Y-axis of the web view. Default is 1.0.</param>
  60. public UniWebViewTransform(float scaleX, float scaleY) {
  61. Rotation = 0.0f;
  62. ScaleX = scaleX;
  63. ScaleY = scaleY;
  64. }
  65. }