The color to use for this node; will be used as 'fillcolor' for its box. See Color::AsHexString. A suitable, different color will be chosen for the 'fontcolor' for the inside text label, see Color::TextColorString. Returns the serialization in graphviz format of a suitable color to use 'fontcolor' in the same boxes. It should black or white, whichever offers the better contrast from AsHexString().
| 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; |
no test coverage detected