MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / Color

Class Color

tensorflow/lite/toco/dump_graphviz.cc:69–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67constexpr char kUnicodeEllipsis[] = " \u2026 ";
68
69class Color {
70 public:
71 Color() {}
72 Color(uint8 r, uint8 g, uint8 b) : r_(r), g_(g), b_(b) {}
73 explicit Color(uint32 word)
74 : r_((word & 0x00FF0000) >> 16),
75 g_((word & 0x0000FF00) >> 8),
76 b_((word & 0x000000FF) >> 0) {}
77
78 // Returns the string serialization of this color in graphviz format,
79 // for use as 'fillcolor' in boxes.
80 string AsHexString() const { return StringF("#%.2X%.2X%.2X", r_, g_, b_); }
81 // The color to use for this node; will be used as 'fillcolor'
82 // for its box. See Color::AsHexString. A suitable, different
83 // color will be chosen for the 'fontcolor' for the inside text
84 // label, see Color::TextColorString.
85 // Returns the serialization in graphviz format of a suitable color to use
86 // 'fontcolor' in the same boxes. It should black or white, whichever offers
87 // the better contrast from AsHexString().
88 string TextColorString() const {
89 // https://en.wikipedia.org/wiki/Relative_luminance
90 const float luminance = 0.2126f * r_ + 0.7152f * g_ + 0.0722f * b_;
91 const uint8 l = luminance > 128.f ? 0 : 255;
92 return StringF("#%.2X%.2X%.2X", l, l, l);
93 }
94
95 private:
96 uint8 r_ = 0, g_ = 0, b_ = 0;
97};
98
99Color HashStringToColor(string s) {
100 // Return a unique color for a name.

Callers 7

HashStringToColorFunction · 0.85
GetArrayColorAndShapeFunction · 0.85
GetOpColorFunction · 0.85
TEST_FFunction · 0.85
BufferValueClass · 0.85
DefaultColorerMethod · 0.85
alias_analysis.ccFile · 0.85

Calls

no outgoing calls

Tested by 1

TEST_FFunction · 0.68