mirror of
https://github.com/allankoechke/raylib-cpp.git
synced 2026-11-30 17:19:27 +00:00
Adding std::string casts to Color, Vector2, Vector3, and Vector4
This commit is contained in:
@@ -66,6 +66,16 @@ class Color : public ::Color {
|
||||
return ::ColorToInt(*this);
|
||||
}
|
||||
|
||||
inline std::string ToString() const {
|
||||
std::ostringstream oss;
|
||||
oss << "Color(" << r << ", " << g << ", " << b << ", " << a << ")";
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
inline operator std::string() const {
|
||||
return ToString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns color with alpha applied, alpha goes from 0.0f to 1.0f
|
||||
*/
|
||||
@@ -210,13 +220,6 @@ class Color : public ::Color {
|
||||
return ::ColorAlphaBlend(dst, *this, tint);
|
||||
}
|
||||
|
||||
inline std::string ToString() const
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "Color(" << r << ", " << g << ", " << b << ", " << a << ")";
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
inline static Color LightGray() { return LIGHTGRAY; }
|
||||
inline static Color Gray() { return GRAY; }
|
||||
inline static Color DarkGray() { return DARKGRAY; }
|
||||
|
||||
@@ -49,6 +49,16 @@ class Vector2 : public ::Vector2 {
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
inline std::string ToString() const {
|
||||
std::ostringstream oss;
|
||||
oss << "Vector2(" << x << ", " << y << ")";
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
inline operator std::string() const {
|
||||
return ToString();
|
||||
}
|
||||
|
||||
#ifndef RAYLIB_CPP_NO_MATH
|
||||
/**
|
||||
* Add two vectors (v1 + v2)
|
||||
@@ -424,13 +434,6 @@ class Vector2 : public ::Vector2 {
|
||||
return ::CheckCollisionPointLine(*this, p1, p2, threshold);
|
||||
}
|
||||
|
||||
inline std::string ToString() const
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "Vector2(" << x << ", " << y << ")";
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
private:
|
||||
void set(const ::Vector2& vec) {
|
||||
x = vec.x;
|
||||
|
||||
@@ -47,6 +47,16 @@ class Vector3 : public ::Vector3 {
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
inline std::string ToString() const {
|
||||
std::ostringstream oss;
|
||||
oss << "Vector3(" << x << ", " << y << ", " << z << ")";
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
inline operator std::string() const {
|
||||
return ToString();
|
||||
}
|
||||
|
||||
#ifndef RAYLIB_CPP_NO_MATH
|
||||
/**
|
||||
* Add two vectors
|
||||
@@ -331,13 +341,6 @@ class Vector3 : public ::Vector3 {
|
||||
return CheckCollisionSpheres(*this, radius1, center2, radius2);
|
||||
}
|
||||
|
||||
inline std::string ToString() const
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "Vector3(" << x << ", " << y << ", " << z << ")";
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
private:
|
||||
void set(const ::Vector3& vec) {
|
||||
x = vec.x;
|
||||
|
||||
@@ -60,6 +60,16 @@ class Vector4 : public ::Vector4 {
|
||||
return {x, y, z, w};
|
||||
}
|
||||
|
||||
inline std::string ToString() const {
|
||||
std::ostringstream oss;
|
||||
oss << "Vector4(" << x << ", " << y << ", " << z << ", " << w << ")";
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
inline operator std::string() const {
|
||||
return ToString();
|
||||
}
|
||||
|
||||
#ifndef RAYLIB_CPP_NO_MATH
|
||||
inline Vector4 Multiply(const ::Vector4& vector4) const {
|
||||
return QuaternionMultiply(*this, vector4);
|
||||
@@ -153,13 +163,6 @@ class Vector4 : public ::Vector4 {
|
||||
return ColorFromNormalized();
|
||||
}
|
||||
|
||||
inline std::string ToString() const
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "Vector4(" << x << ", " << y << ", " << z << ", " << w << ")";
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
private:
|
||||
void set(const ::Vector4& vec4) {
|
||||
x = vec4.x;
|
||||
|
||||
Reference in New Issue
Block a user