mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:37:44 +00:00
LibGfx: Add ::xyz()
swizzle operator to Vector4
This commit is contained in:
parent
53ed93d909
commit
38fc7361ca
1 changed files with 8 additions and 0 deletions
|
@ -10,6 +10,9 @@
|
||||||
#include <AK/String.h>
|
#include <AK/String.h>
|
||||||
|
|
||||||
namespace Gfx {
|
namespace Gfx {
|
||||||
|
template<typename T>
|
||||||
|
class Vector3;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class Vector4 final {
|
class Vector4 final {
|
||||||
public:
|
public:
|
||||||
|
@ -131,6 +134,11 @@ public:
|
||||||
return AK::sqrt(m_x * m_x + m_y * m_y + m_z * m_z + m_w * m_w);
|
return AK::sqrt(m_x * m_x + m_y * m_y + m_z * m_z + m_w * m_w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr Vector3<T> xyz() const
|
||||||
|
{
|
||||||
|
return Vector3<T>(m_x, m_y, m_z);
|
||||||
|
}
|
||||||
|
|
||||||
String to_string() const
|
String to_string() const
|
||||||
{
|
{
|
||||||
return String::formatted("[{},{},{},{}]", x(), y(), z(), w());
|
return String::formatted("[{},{},{},{}]", x(), y(), z(), w());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue