Rectangle.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /**
  2. * The MIT License (MIT)
  3. *
  4. * Copyright (c) 2012-2017 DragonBones team and other contributors
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  7. * this software and associated documentation files (the "Software"), to deal in
  8. * the Software without restriction, including without limitation the rights to
  9. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  10. * the Software, and to permit persons to whom the Software is furnished to do so,
  11. * subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in all
  14. * copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  18. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  19. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  20. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  21. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22. */
  23. namespace DragonBones
  24. {
  25. /// <summary>
  26. /// - A Rectangle object is an area defined by its position, as indicated by its top-left corner point (x, y) and by its
  27. /// width and its height.<br/>
  28. /// The x, y, width, and height properties of the Rectangle class are independent of each other; changing the value of
  29. /// one property has no effect on the others. However, the right and bottom properties are integrally related to those
  30. /// four properties. For example, if you change the value of the right property, the value of the width property changes;
  31. /// if you change the bottom property, the value of the height property changes.
  32. /// </summary>
  33. /// <version>DragonBones 3.0</version>
  34. /// <language>en_US</language>
  35. /// <summary>
  36. /// - Rectangle 对象是按其位置(由它左上角的点 (x, y) 确定)以及宽度和高度定义的区域。<br/>
  37. /// Rectangle 类的 x、y、width 和 height 属性相互独立;更改一个属性的值不会影响其他属性。
  38. /// 但是,right 和 bottom 属性与这四个属性是整体相关的。例如,如果更改 right 属性的值,则 width
  39. /// 属性的值将发生变化;如果更改 bottom 属性,则 height 属性的值将发生变化。
  40. /// </summary>
  41. /// <version>DragonBones 3.0</version>
  42. /// <language>zh_CN</language>
  43. public class Rectangle
  44. {
  45. /// <summary>
  46. /// - The x coordinate of the top-left corner of the rectangle.
  47. /// </summary>
  48. /// <default>0.0</default>
  49. /// <version>DragonBones 3.0</version>
  50. /// <language>en_US</language>
  51. /// <summary>
  52. /// - 矩形左上角的 x 坐标。
  53. /// </summary>
  54. /// <default>0.0</default>
  55. /// <version>DragonBones 3.0</version>
  56. /// <language>zh_CN</language>
  57. public float x;
  58. /// <summary>
  59. /// - The y coordinate of the top-left corner of the rectangle.
  60. /// </summary>
  61. /// <default>0.0</default>
  62. /// <version>DragonBones 3.0</version>
  63. /// <language>en_US</language>
  64. /// <summary>
  65. /// - 矩形左上角的 y 坐标。
  66. /// </summary>
  67. /// <default>0.0</default>
  68. /// <version>DragonBones 3.0</version>
  69. /// <language>zh_CN</language>
  70. public float y;
  71. /// <summary>
  72. /// - The width of the rectangle, in pixels.
  73. /// </summary>
  74. /// <default>0.0</default>
  75. /// <version>DragonBones 3.0</version>
  76. /// <language>en_US</language>
  77. /// <summary>
  78. /// - 矩形的宽度(以像素为单位)。
  79. /// </summary>
  80. /// <default>0.0</default>
  81. /// <version>DragonBones 3.0</version>
  82. /// <language>zh_CN</language>
  83. public float width;
  84. /// <summary>
  85. /// - 矩形的高度(以像素为单位)。
  86. /// </summary>
  87. /// <default>0.0</default>
  88. /// <version>DragonBones 3.0</version>
  89. /// <language>en_US</language>
  90. /// <summary>
  91. /// - The height of the rectangle, in pixels.
  92. /// </summary>
  93. /// <default>0.0</default>
  94. /// <version>DragonBones 3.0</version>
  95. /// <language>zh_CN</language>
  96. public float height;
  97. /// <private/>
  98. public Rectangle()
  99. {
  100. }
  101. /// <private/>
  102. public void CopyFrom(Rectangle value)
  103. {
  104. this.x = value.x;
  105. this.y = value.y;
  106. this.width = value.width;
  107. this.height = value.height;
  108. }
  109. /// <private/>
  110. public void Clear()
  111. {
  112. this.x = this.y = 0.0f;
  113. this.width = this.height = 0.0f;
  114. }
  115. }
  116. }