矩形模板类 更多...
#include <Rect.hpp>
Public 成员函数 | |
| constexpr | Rect (const Point< T > &pos, const Size< T > &size) |
| 构造函数 | |
| constexpr | Rect (const Rect< T > &other)=default |
| constexpr | Rect (const Size< T > &size) |
| 构造函数 | |
| constexpr | Rect (Rect< T > &&other)=default |
| constexpr | Rect (T x=static_cast< T >(0), T y=static_cast< T >(0), T width=static_cast< T >(0), T height=static_cast< T >(0)) |
| 构造函数 | |
| constexpr T | bottom () const |
| 矩形的下侧边界坐标 | |
| constexpr Point< T > | center () const |
| 矩形的中心点坐标 | |
| constexpr Rect< T > | centerby (const Size< T > &size) const |
| 计算给定尺寸的居中矩形 | |
| constexpr T & | height () |
| 矩形高度 | |
| constexpr const T & | height () const |
| 矩形高度的 const 版本 | |
| constexpr T | left () const |
| 矩形的左侧边界坐标 | |
| constexpr void | normalize () |
| 规范化矩形数据 | |
| constexpr | operator bool () const |
| 将矩形转换到 bool 值 | |
| template<typename U > requires std::is_arithmetic_v<U> | |
| constexpr | operator Rect< U > () const |
| 矩形类型转换函数 | |
| constexpr bool | operator! () const |
| 逻辑非运算符重载 | |
| constexpr bool | operator!= (const Rect< T > &other) const |
| 不等于比较运算符重载 | |
| constexpr Rect< T > & | operator= (const Rect< T > &other)=default |
| constexpr Rect< T > & | operator= (Rect< T > &&other)=default |
| constexpr bool | operator== (const Rect< T > &other) const |
| 等于比较运算符重载 | |
| constexpr Point< T > & | position () |
| 矩形左上角的坐标 | |
| constexpr const Point< T > & | position () const |
| 矩形左上角的坐标的 const 版本 | |
| constexpr T | right () const |
| 矩形的右侧边界坐标 | |
| constexpr Size< T > & | size () |
| 矩形大小 | |
| constexpr const Size< T > & | size () const |
| 矩形大小的 const 版本 | |
| constexpr T | top () const |
| 矩形的上侧边界坐标 | |
| constexpr T & | width () |
| 矩形宽度 | |
| constexpr const T & | width () const |
| 矩形宽度的 const 版本 | |
| constexpr T & | x () |
| 矩形位置的 x 坐标 | |
| constexpr const T & | x () const |
| 矩形位置的 x 坐标的 const 版本 | |
| constexpr T & | y () |
| 矩形位置的 y 坐标 | |
| constexpr const T & | y () const |
| 矩形位置的 y 坐标的 const 版本 | |
友元 | |
| std::ostream & | operator<< (std::ostream &os, const Rect< T > &rect) |
| 流操作符重载 | |
矩形模板类
矩形模板类,用于表示矩形的几何信息,包括位置和大小
此类是 基础设施库 => 图形数据类型 的一部分
| T | 数值类型,要求为算术类型 |
|
inlineexplicitconstexpr |
构造函数
| x | 矩形左上角的x坐标 |
| y | 矩形左上角的y坐标 |
| width | 矩形的宽度 |
| height | 矩形的高度 |
|
inlineconstexpr |
构造函数
| pos | 矩形左上角的坐标 |
| size | 矩形的大小 |
构造函数
| size | 矩形的大小 |
只从矩形的大小构造矩形,矩形左上角的坐标为 (0, 0)
|
inlineconstexpr |
计算给定尺寸的居中矩形
| size | 矩形的大小 |
矩形高度的 const 版本
将矩形转换到 bool 值
矩形位置和大小转换到 bool 值时,均为 false 则返回 false,否则返回 true
矩形类型转换函数
| U | 目标类型 |
逻辑非运算符重载
相当于转化为 bool 值再取反
|
inlineconstexpr |
不等于比较运算符重载
此函数对于浮点数比较是安全的
| other | 另一个矩形对象 |
|
constexprdefault |
|
inlineconstexpr |
等于比较运算符重载
此函数对于浮点数比较是安全的
| other | 另一个矩形对象 |
矩形左上角的坐标的 const 版本
矩形大小的 const 版本
矩形宽度的 const 版本
矩形位置的 x 坐标的 const 版本
矩形位置的 y 坐标的 const 版本