mirror of
https://github.com/allankoechke/raylib-cpp.git
synced 2026-12-01 01:18:52 +00:00
Adding ToString() func to Color, Vector2, Vector3, and Vector4 classes
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_COLOR_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_COLOR_HPP_
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include "./raylib.hpp"
|
||||
@@ -209,6 +210,13 @@ 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; }
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#include <cmath>
|
||||
#endif
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "./raylib.hpp"
|
||||
#include "./raymath.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
@@ -422,6 +424,13 @@ 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;
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#include <cmath>
|
||||
#endif
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "./raylib.hpp"
|
||||
#include "./raymath.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
@@ -329,6 +331,13 @@ 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;
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include <utility>
|
||||
#endif
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "./raylib.hpp"
|
||||
#include "./raymath.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
@@ -151,6 +153,13 @@ 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