Implement UDim::Equals and UDim::Lerp
This commit is contained in:
@@ -11,6 +11,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "J3ML/J3ML.hpp"
|
||||
|
||||
namespace JUI
|
||||
{
|
||||
/// A coordinate system data type for user interfaces specifically.
|
||||
@@ -32,6 +34,10 @@ namespace JUI
|
||||
UDim operator * (float rhs) const;
|
||||
|
||||
UDim operator / (float rhs) const;
|
||||
|
||||
bool Equals(const UDim& rhs, float epsilon = 1e-3f);
|
||||
|
||||
UDim Lerp(const UDim& goal, float t);
|
||||
};
|
||||
|
||||
namespace UDimLiterals {
|
||||
|
@@ -31,3 +31,16 @@ JUI::UDim JUI::UDim::operator*(float rhs) const {
|
||||
JUI::UDim JUI::UDim::operator/(float rhs) const {
|
||||
return {static_cast<int>(Pixels / rhs), Scale/rhs};
|
||||
}
|
||||
|
||||
JUI::UDim JUI::UDim::Lerp(const JUI::UDim &goal, float t) {
|
||||
float scale = J3ML::Math::Lerp(Scale, goal.Scale, t);
|
||||
float pixels = J3ML::Math::Lerp(Pixels, goal.Pixels, t);
|
||||
|
||||
return UDim(pixels, scale);
|
||||
}
|
||||
|
||||
bool JUI::UDim::Equals(const JUI::UDim &rhs, float epsilon) {
|
||||
return J3ML::Math::Equal((float)Pixels, rhs.Pixels, epsilon)
|
||||
&& J3ML::Math::Equal(Scale, rhs.Scale, epsilon);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user