@@ 122-130 (lines=9) @@ | ||
119 | * |
|
120 | * @return string web-safe hex string |
|
121 | */ |
|
122 | public function web_safe() :string { |
|
123 | if (!is_null($cached = $this->cache->get(__FUNCTION__, $this->hex()))) { |
|
124 | return $cached; |
|
125 | } |
|
126 | $rgb = $this->color->rgb; |
|
127 | $result = generate::web_safe($rgb['r'], $rgb['g'], $rgb['b']); |
|
128 | $this->cache->set(__FUNCTION__, $this->hex(), $result); |
|
129 | return $result; |
|
130 | } |
|
131 | ||
132 | /** |
|
133 | * Return the current color as an CSS value |
|
@@ 157-165 (lines=9) @@ | ||
154 | * @param int $check_score Minimum score to be considered light (0-255; defaults to 128) |
|
155 | * @return bool |
|
156 | */ |
|
157 | public function is_dark(int $check_score = 128) :bool { |
|
158 | if (!is_null($cached = $this->cache->get(__FUNCTION__, $this->hex()))) { |
|
159 | return $cached; |
|
160 | } |
|
161 | $rgb = $this->color->rgb; |
|
162 | $result = check::is_dark($rgb['r'], $rgb['g'], $rgb['b'], $check_score); |
|
163 | $this->cache->set(__FUNCTION__, $this->hex(), $result); |
|
164 | return $result; |
|
165 | } |
|
166 | ||
167 | /** |
|
168 | * Adjust the red value of the current color |