[wpilib] Improve Color.toString (#4450)

This commit is contained in:
Starlight220
2022-10-04 22:36:51 +03:00
committed by GitHub
parent 5c067d30a0
commit 3b81cf6c35
9 changed files with 290 additions and 149 deletions

View File

@@ -79,7 +79,7 @@ class Mechanism2d : public nt::NTSendable,
private:
double m_width;
double m_height;
char m_color[10];
std::string m_color;
mutable wpi::mutex m_mutex;
std::shared_ptr<nt::NetworkTable> m_table;
wpi::StringMap<std::unique_ptr<MechanismRoot2d>> m_roots;

View File

@@ -5,6 +5,7 @@
#pragma once
#include <algorithm>
#include <string>
namespace frc {
@@ -808,6 +809,13 @@ class Color {
}
}
/**
* Return this color represented as a hex string.
*
* @return a string of the format <tt>\#RRGGBB</tt>
*/
std::string HexString() const;
double red = 0.0;
double green = 0.0;
double blue = 0.0;

View File

@@ -5,6 +5,7 @@
#pragma once
#include <algorithm>
#include <string>
#include "Color.h"
@@ -43,6 +44,13 @@ class Color8Bit {
return Color(red / 255.0, green / 255.0, blue / 255.0);
}
/**
* Return this color represented as a hex string.
*
* @return a string of the format <tt>\#RRGGBB</tt>
*/
std::string HexString() const;
int red = 0;
int green = 0;
int blue = 0;