mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 07:03:25 +00:00
added color
This commit is contained in:
@@ -3,11 +3,20 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "uml/Vector3.h"
|
#include "uml/Vector3.h"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include "uml/Vector4.h"
|
||||||
|
|
||||||
|
|
||||||
namespace uml::color
|
namespace uml::color
|
||||||
{
|
{
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
Vector3 Blend(const Vector3& first, const Vector3& second, float ratio);
|
Vector3 Blend(const Vector3& first, const Vector3& second, float ratio);
|
||||||
|
|
||||||
|
class Color : public Vector4
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
[[nodiscard]] Color Blend(const Color& other, float ratio) const;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
@@ -3,11 +3,17 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "uml/color.h"
|
#include "uml/color.h"
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
namespace uml::color
|
namespace uml::color
|
||||||
{
|
{
|
||||||
Vector3 Blend(const uml::Vector3 &first, const uml::Vector3 &second, float ratio)
|
Vector3 Blend(const Vector3 &first, const Vector3 &second, float ratio)
|
||||||
{
|
{
|
||||||
return first * (1.f - ratio) + second * ratio;
|
return first * (1.f - std::clamp(ratio, 0.f, 1.f)) + second * ratio;
|
||||||
|
}
|
||||||
|
|
||||||
|
Color Color::Blend(const Color &other, float ratio) const
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user