mirror of
https://github.com/allankoechke/raylib-cpp.git
synced 2026-12-05 17:25:42 +00:00
Merge pull request #249 from dbrats/toString
Adding ToString() and std::string cast to Color and Vector classes
This commit is contained in:
@@ -65,6 +65,14 @@ class Color : public ::Color {
|
||||
return ::ColorToInt(*this);
|
||||
}
|
||||
|
||||
inline std::string ToString() const {
|
||||
return TextFormat("Color(%d, %d, %d, %d)", r, g, b, a);
|
||||
}
|
||||
|
||||
inline operator std::string() const {
|
||||
return ToString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns color with alpha applied, alpha goes from 0.0f to 1.0f
|
||||
*/
|
||||
|
||||
@@ -47,6 +47,14 @@ class Vector2 : public ::Vector2 {
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
inline std::string ToString() const {
|
||||
return TextFormat("Vector2(%f, %f)", x, y);
|
||||
}
|
||||
|
||||
inline operator std::string() const {
|
||||
return ToString();
|
||||
}
|
||||
|
||||
#ifndef RAYLIB_CPP_NO_MATH
|
||||
/**
|
||||
* Add two vectors (v1 + v2)
|
||||
|
||||
@@ -45,6 +45,14 @@ class Vector3 : public ::Vector3 {
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
inline std::string ToString() const {
|
||||
return TextFormat("Vector3(%f, %f, %f)", x, y, z);
|
||||
}
|
||||
|
||||
inline operator std::string() const {
|
||||
return ToString();
|
||||
}
|
||||
|
||||
#ifndef RAYLIB_CPP_NO_MATH
|
||||
/**
|
||||
* Add two vectors
|
||||
|
||||
@@ -58,6 +58,14 @@ class Vector4 : public ::Vector4 {
|
||||
return {x, y, z, w};
|
||||
}
|
||||
|
||||
inline std::string ToString() const {
|
||||
return TextFormat("Vector4(%f, %f, %f, %f)", x, y, z, w);
|
||||
}
|
||||
|
||||
inline operator std::string() const {
|
||||
return ToString();
|
||||
}
|
||||
|
||||
#ifndef RAYLIB_CPP_NO_MATH
|
||||
inline Vector4 Multiply(const ::Vector4& vector4) const {
|
||||
return QuaternionMultiply(*this, vector4);
|
||||
|
||||
Reference in New Issue
Block a user