# Changes 0.2.4-1
- Add GIT_BRANCH (for development and stable) - Write Documentation of - pd-core (exept of vec.hpp) - pd-app - pd-drivers - pd-lib3ds - pd-image - pd-image - pd-ui7
This commit is contained in:
		| @@ -28,64 +28,156 @@ SOFTWARE. | ||||
|  | ||||
| namespace PD { | ||||
| namespace LI { | ||||
| /// @brief Container that holds top and bottom corners of a quad | ||||
| /** | ||||
|  * Container that holds position of a rectangle's corners. | ||||
|  */ | ||||
| class Rect { | ||||
|  public: | ||||
|   Rect() = default; | ||||
|  | ||||
|   /** | ||||
|    * Constructor that initializes the rectangle using top and bottom positions. | ||||
|    * @param t Top left and right corner positions. | ||||
|    * @param b Bottom left and right corner positions. | ||||
|    */ | ||||
|   Rect(const vec4& t, const vec4& b) { | ||||
|     top = t; | ||||
|     bot = b; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Constructor that initializes the rectangle using individual corner | ||||
|    * positions. | ||||
|    * @param tl Top left corner position. | ||||
|    * @param tr Top right corner position. | ||||
|    * @param bl Bottom left corner position. | ||||
|    * @param br Bottom right corner position. | ||||
|    */ | ||||
|   Rect(const vec2& tl, const vec2& tr, const vec2& bl, const vec2& br) { | ||||
|     top = vec4(tl, tr); | ||||
|     bot = vec4(bl, br); | ||||
|   } | ||||
|   /// This Constructor Fixes the issue of rewriting some Stuff in the Text | ||||
|   /// Renderer | ||||
|  | ||||
|   /** | ||||
|    * Constructor that initializes the rectangle using a UV mapping vector. | ||||
|    * | ||||
|    * - The old API used vec4 for UV mapping. | ||||
|    * - Spritesheets have rotated images, so this was updated to use Rect for UV. | ||||
|    * | ||||
|    * @param uv Vec4 UV map. | ||||
|    */ | ||||
|   Rect(const vec4& uv) { | ||||
|     top = vec4(uv.x(), uv.y(), uv.z(), uv.y()); | ||||
|     bot = vec4(uv.x(), uv.w(), uv.z(), uv.w()); | ||||
|   } | ||||
|  | ||||
|   ~Rect() = default; | ||||
|  | ||||
|   /** | ||||
|    * Get the top left and right corner positions. | ||||
|    * @return Top positions. | ||||
|    */ | ||||
|   vec4 Top() const { return top; } | ||||
|  | ||||
|   /** | ||||
|    * Get the bottom left and right corner positions. | ||||
|    * @return Bottom positions. | ||||
|    */ | ||||
|   vec4 Bot() const { return bot; } | ||||
|  | ||||
|   /** | ||||
|    * Set the top left and right corner positions. | ||||
|    * @param v New top positions. | ||||
|    * @return Reference to the updated Rect. | ||||
|    */ | ||||
|   Rect& Top(const vec4& v) { | ||||
|     top = v; | ||||
|     return *this; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Set the bottom left and right corner positions. | ||||
|    * @param v New bottom positions. | ||||
|    * @return Reference to the updated Rect. | ||||
|    */ | ||||
|   Rect& Bot(const vec4& v) { | ||||
|     bot = v; | ||||
|     return *this; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Get the top-left corner position. | ||||
|    * @return Top-left position as vec2. | ||||
|    */ | ||||
|   vec2 TopLeft() const { return vec2(top[0], top[1]); } | ||||
|  | ||||
|   /** | ||||
|    * Get the top-right corner position. | ||||
|    * @return Top-right position as vec2. | ||||
|    */ | ||||
|   vec2 TopRight() const { return vec2(top[2], top[3]); } | ||||
|  | ||||
|   /** | ||||
|    * Get the bottom-left corner position. | ||||
|    * @return Bottom-left position as vec2. | ||||
|    */ | ||||
|   vec2 BotLeft() const { return vec2(bot[0], bot[1]); } | ||||
|  | ||||
|   /** | ||||
|    * Get the bottom-right corner position. | ||||
|    * @return Bottom-right position as vec2. | ||||
|    */ | ||||
|   vec2 BotRight() const { return vec2(bot[2], bot[3]); } | ||||
|  | ||||
|   /** | ||||
|    * Set the top-left corner position. | ||||
|    * @param v New top-left position. | ||||
|    * @return Reference to the updated Rect. | ||||
|    */ | ||||
|   Rect& TopLeft(const vec2& v) { | ||||
|     top[0] = v[0]; | ||||
|     top[1] = v[1]; | ||||
|     return *this; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Set the top-right corner position. | ||||
|    * @param v New top-right position. | ||||
|    * @return Reference to the updated Rect. | ||||
|    */ | ||||
|   Rect& TopRight(const vec2& v) { | ||||
|     top[2] = v[0]; | ||||
|     top[3] = v[1]; | ||||
|     return *this; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Set the bottom-left corner position. | ||||
|    * @param v New bottom-left position. | ||||
|    * @return Reference to the updated Rect. | ||||
|    */ | ||||
|   Rect& BotLeft(const vec2& v) { | ||||
|     bot[0] = v[0]; | ||||
|     bot[1] = v[1]; | ||||
|     return *this; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Set the bottom-right corner position. | ||||
|    * @param v New bottom-right position. | ||||
|    * @return Reference to the updated Rect. | ||||
|    */ | ||||
|   Rect& BotRight(const vec2& v) { | ||||
|     bot[2] = v[0]; | ||||
|     bot[3] = v[1]; | ||||
|     return *this; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Swap X and Y coordinates for all corners. | ||||
|    * | ||||
|    * - Used in SpiteSheet for the rotated images. | ||||
|    */ | ||||
|   void SwapVec2XY() { | ||||
|     for (int i = 0; i < 4; i += 2) { | ||||
|       float t = top[i]; | ||||
| @@ -98,8 +190,8 @@ class Rect { | ||||
|   } | ||||
|  | ||||
|  private: | ||||
|   vec4 top; | ||||
|   vec4 bot; | ||||
|   vec4 top;  ///< Top left and right corner positions. | ||||
|   vec4 bot;  ///< Bottom left and right corner positions. | ||||
| }; | ||||
| }  // namespace LI | ||||
| }  // namespace PD | ||||
		Reference in New Issue
	
	Block a user