GraceFt v2.3
开源图形引擎 EGE(Easy Graphics Engine) 的高层封装库
 
载入中...
搜索中...
未找到
GFt::Rect< T > 模板类 参考

矩形模板类 更多...

#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< Tcenter () const
 矩形的中心点坐标
 
constexpr Rect< Tcenterby (const Size< T > &size) const
 计算给定尺寸的居中矩形
 
constexpr Theight ()
 矩形高度
 
constexpr const Theight () 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 Twidth ()
 矩形宽度
 
constexpr const Twidth () const
 矩形宽度的 const 版本
 
constexpr Tx ()
 矩形位置的 x 坐标
 
constexpr const Tx () const
 矩形位置的 x 坐标的 const 版本
 
constexpr Ty ()
 矩形位置的 y 坐标
 
constexpr const Ty () const
 矩形位置的 y 坐标的 const 版本
 

友元

std::ostream & operator<< (std::ostream &os, const Rect< T > &rect)
 流操作符重载
 

详细描述

template<typename T>
requires std::is_arithmetic_v<T>
class GFt::Rect< T >

矩形模板类

矩形模板类,用于表示矩形的几何信息,包括位置和大小

此类是 基础设施库 => 图形数据类型 的一部分

模板参数
T数值类型,要求为算术类型

构造及析构函数说明

◆ Rect() [1/5]

template<typename T >
GFt::Rect< T >::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) )
inlineexplicitconstexpr

构造函数

参数
x矩形左上角的x坐标
y矩形左上角的y坐标
width矩形的宽度
height矩形的高度

◆ Rect() [2/5]

template<typename T >
GFt::Rect< T >::Rect ( const Point< T > & pos,
const Size< T > & size )
inlineconstexpr

构造函数

参数
pos矩形左上角的坐标
size矩形的大小

◆ Rect() [3/5]

template<typename T >
GFt::Rect< T >::Rect ( const Size< T > & size)
inlineconstexpr

构造函数

参数
size矩形的大小

只从矩形的大小构造矩形,矩形左上角的坐标为 (0, 0)

◆ Rect() [4/5]

template<typename T >
GFt::Rect< T >::Rect ( const Rect< T > & other)
constexprdefault

◆ Rect() [5/5]

template<typename T >
GFt::Rect< T >::Rect ( Rect< T > && other)
constexprdefault

成员函数说明

◆ bottom()

template<typename T >
T GFt::Rect< T >::bottom ( ) const
inlineconstexpr

矩形的下侧边界坐标

返回
坐标值

◆ center()

template<typename T >
Point< T > GFt::Rect< T >::center ( ) const
inlineconstexpr

矩形的中心点坐标

返回
坐标值

◆ centerby()

template<typename T >
Rect< T > GFt::Rect< T >::centerby ( const Size< T > & size) const
inlineconstexpr

计算给定尺寸的居中矩形

参数
size矩形的大小
返回
矩形对象

◆ height() [1/2]

template<typename T >
T & GFt::Rect< T >::height ( )
inlineconstexpr

矩形高度

返回
高度值

◆ height() [2/2]

template<typename T >
const T & GFt::Rect< T >::height ( ) const
inlineconstexpr

矩形高度的 const 版本

返回
高度值

◆ left()

template<typename T >
T GFt::Rect< T >::left ( ) const
inlineconstexpr

矩形的左侧边界坐标

返回
坐标值

◆ normalize()

template<typename T >
void GFt::Rect< T >::normalize ( )
inlineconstexpr

规范化矩形数据

确保矩形的宽度和高度都不小于 0

◆ operator bool()

template<typename T >
GFt::Rect< T >::operator bool ( ) const
inlineexplicitconstexpr

将矩形转换到 bool 值

矩形位置和大小转换到 bool 值时,均为 false 则返回 false,否则返回 true

返回
转换结果

◆ operator Rect< U >()

template<typename T >
template<typename U >
requires std::is_arithmetic_v<U>
GFt::Rect< T >::operator Rect< U > ( ) const
inlineconstexpr

矩形类型转换函数

模板参数
U目标类型
返回
转换后的矩形对象

◆ operator!()

template<typename T >
bool GFt::Rect< T >::operator! ( ) const
inlineconstexpr

逻辑非运算符重载

相当于转化为 bool 值再取反

返回
逻辑非运算结果

◆ operator!=()

template<typename T >
bool GFt::Rect< T >::operator!= ( const Rect< T > & other) const
inlineconstexpr

不等于比较运算符重载

此函数对于浮点数比较是安全的

参数
other另一个矩形对象
返回
不相等返回 true,否则返回 false

◆ operator=() [1/2]

template<typename T >
Rect< T > & GFt::Rect< T >::operator= ( const Rect< T > & other)
constexprdefault

◆ operator=() [2/2]

template<typename T >
Rect< T > & GFt::Rect< T >::operator= ( Rect< T > && other)
constexprdefault

◆ operator==()

template<typename T >
bool GFt::Rect< T >::operator== ( const Rect< T > & other) const
inlineconstexpr

等于比较运算符重载

此函数对于浮点数比较是安全的

参数
other另一个矩形对象
返回
相等返回 true,否则返回 false

◆ position() [1/2]

template<typename T >
Point< T > & GFt::Rect< T >::position ( )
inlineconstexpr

矩形左上角的坐标

返回
坐标值

◆ position() [2/2]

template<typename T >
const Point< T > & GFt::Rect< T >::position ( ) const
inlineconstexpr

矩形左上角的坐标的 const 版本

返回
坐标值

◆ right()

template<typename T >
T GFt::Rect< T >::right ( ) const
inlineconstexpr

矩形的右侧边界坐标

返回
坐标值

◆ size() [1/2]

template<typename T >
Size< T > & GFt::Rect< T >::size ( )
inlineconstexpr

矩形大小

返回
大小值

◆ size() [2/2]

template<typename T >
const Size< T > & GFt::Rect< T >::size ( ) const
inlineconstexpr

矩形大小的 const 版本

返回
大小值

◆ top()

template<typename T >
T GFt::Rect< T >::top ( ) const
inlineconstexpr

矩形的上侧边界坐标

返回
坐标值

◆ width() [1/2]

template<typename T >
T & GFt::Rect< T >::width ( )
inlineconstexpr

矩形宽度

返回
宽度值

◆ width() [2/2]

template<typename T >
const T & GFt::Rect< T >::width ( ) const
inlineconstexpr

矩形宽度的 const 版本

返回
宽度值

◆ x() [1/2]

template<typename T >
T & GFt::Rect< T >::x ( )
inlineconstexpr

矩形位置的 x 坐标

返回
坐标值

◆ x() [2/2]

template<typename T >
const T & GFt::Rect< T >::x ( ) const
inlineconstexpr

矩形位置的 x 坐标的 const 版本

返回
坐标值

◆ y() [1/2]

template<typename T >
T & GFt::Rect< T >::y ( )
inlineconstexpr

矩形位置的 y 坐标

返回
坐标值

◆ y() [2/2]

template<typename T >
const T & GFt::Rect< T >::y ( ) const
inlineconstexpr

矩形位置的 y 坐标的 const 版本

返回
坐标值

友元及相关符号说明

◆ operator<<

template<typename T >
std::ostream & operator<< ( std::ostream & os,
const Rect< T > & rect )
friend

流操作符重载

参数
os输出流
rect矩形对象
返回
输出流 os