Checks brightness($color) >= $threshold. Accepts an optional $threshold float as the last parameter with a default of 127.5.

@param string|array $color
@param float $threshold
@return bool
770778
public function isBright($color, $threshold=127.5): bool
    {
        return Plugin::$plugin->color->isBright($color, $threshold);
    }
683334
public static function hsla(Color $color, float $alpha = 1.0)
    {
        $hsl = $color->getHsl();

        return sprintf(
            'hsla(%s, %s%%, %s%%, %s)',
            sprintf('%0.1f', $hsl['h'] * 360) + 0,
            sprintf('%0.1f', $hsl['s'] * 100) + 0,
            sprintf('%0.1f', $hsl['l'] * 100) + 0,
            $alpha + 0
        );
    }
559726
protected function _prepColor($color) {
		if (strpos($color, '#') !== false) {
			return str_replace('#', '0x', $color);
		}
		if (is_numeric($color)) {
			return '0x' . $color;
		}
		return $color;
	}
534601
public function luminosityContrast(Color $color): float
    {
        $colorLuminosity1 = $this->getLuminosity() + 0.05;
        $colorLuminosity2 = $color->getLuminosity() + 0.05;

        return max($colorLuminosity1, $colorLuminosity2) / min($colorLuminosity1, $colorLuminosity2);
    }
950808
public function getBrightnessDifference($color1, $color2): float
    {
        return Plugin::$plugin->color->getBrightnessDifference($color1, $color2);
    }
1129690
public void setLighter(Color color)
	{
		int red   = Math.min(255, (int)(color.getRed() * 1.2));
		int green = Math.min(255, (int)(color.getGreen() * 1.2));
		int blue  = Math.min(255, (int)(color.getBlue() * 1.2));
		setColor(new Color(red, green, blue));
	}
679307
def similar_to?(other, threshold: DEFAULT_SIMILAR_THRESHOLD)
      return false unless other.is_a?(Color)
      conditions = []

      conditions << (((hue - other.hue).abs < (threshold * 360)) || begin
        # FIXME: Surely there's a better way.
        hues = [hue, other.hue].sort
        hues[0] += 360
        (hues[0] - hues[1]).abs < (threshold * 360)
      end)
      conditions << ((saturation - other.saturation).abs < threshold)
      conditions << ((brightness - other.brightness).abs < threshold)
      conditions.all?
    end
209044
public void setThresholdColor(final Color COLOR) {
        if (null == thresholdColor) {
            _thresholdColor = COLOR;
            fireTileEvent(REDRAW_EVENT);
        } else {
            thresholdColor.set(COLOR);
        }
    }
918420
public void setThreshold(double threshold)
    {
        if(Double.isNaN(threshold) || threshold <= 0)
            throw new IllegalArgumentException("Threshold must be positive, not " + threshold);
        this.threshold = threshold;
    }
1323226
public function isPositiveColor($color, $type)
    {
        if (empty($this->positiveColors[$type])) {
            return false;
        }

        return in_array($color, $this->positiveColors[$type]);
    }
1350941
private function convertColor($color)
    {
        if (is_array($color)) {
            return $color;
        }

        if (preg_match('/^#?([a-z\d])([a-z\d])([a-z\d])$/i', $color, $matches)) {
            $color = $matches[1].$matches[1];
            $color .= $matches[2].$matches[2];
            $color .= $matches[3].$matches[3];
        }

        preg_match('/#?([a-z\d]{2})([a-z\d]{2})([a-z\d]{2})$/i', $color, $matches);

        return array_map(function ($value) {
            return hexdec($value);
        }, array_slice($matches, 1, 3));
    }
1258394
protected function normalize_color($color) {
        if (is_string($color)) {
            $color = trim($color, '#');
            if (strlen($color) == 6) {
                list($r, $g, $b) = array(
                    $color[0] . $color[1],
                    $color[2] . $color[3],
                    $color[4] . $color[5]
                );
            } elseif (strlen($color) == 3) {
                list($r, $g, $b) = array(
                    $color[0] . $color[0],
                    $color[1] . $color[1],
                    $color[2] . $color[2]
                );
            } else {
                return false;
            }
            return array(
                'r' => hexdec($r),
                'g' => hexdec($g),
                'b' => hexdec($b),
                'a' => 0
            );
        } elseif (is_array($color) && (count($color) == 3 || count($color) == 4)) {
            if (isset($color['r'], $color['g'], $color['b'])) {
                return array(
                    'r' => $this->keep_within($color['r'], 0, 255),
                    'g' => $this->keep_within($color['g'], 0, 255),
                    'b' => $this->keep_within($color['b'], 0, 255),
                    'a' => $this->keep_within(isset($color['a']) ? $color['a'] : 0, 0, 127)
                );
            } elseif (isset($color[0], $color[1], $color[2])) {
                return array(
                    'r' => $this->keep_within($color[0], 0, 255),
                    'g' => $this->keep_within($color[1], 0, 255),
                    'b' => $this->keep_within($color[2], 0, 255),
                    'a' => $this->keep_within(isset($color[3]) ? $color[3] : 0, 0, 127)
                );
            }
        }
        return false;
    }
843067
public void setThreshold(final double THRESHOLD) {
        if (Double.compare(THRESHOLD, minValue) >= 0 && Double.compare(THRESHOLD, maxValue) <= 0) {
            threshold = THRESHOLD;
        } else {
            if (THRESHOLD < niceMinValue) {
                threshold = niceMinValue;
            }

            if (THRESHOLD > niceMaxValue) {
                threshold = niceMaxValue;
            }
        }
        fireStateChanged();
    }
574769
public function looksBright($color, $threshold=127.5): bool
    {
        return Plugin::$plugin->color->looksBright($color, $threshold);
    }
875533
public function getColorDifference($color1, $color2): int
    {
        $c1 = color($color1);
        $c2 = color($color2);
        return color_difference($c1, $c2);
    }
441213
public static function hsl(Color $color)
    {
        $hsl = $color->getHsl();

        return sprintf(
            'hsl(%s, %s%%, %s%%)',
            sprintf('%0.1f', $hsl['h'] * 360) + 0,
            sprintf('%0.1f', $hsl['s'] * 100) + 0,
            sprintf('%0.1f', $hsl['l'] * 100) + 0
        );
    }
1337893
private static function _readColor($color,$palette,$version)
	{
		if ($color <= 0x07 || $color >= 0x40) {
			// special built-in color
			return self::_mapBuiltInColor($color);
		} elseif (isset($palette) && isset($palette[$color - 8])) {
			// palette color, color index 0x08 maps to pallete index 0
			return $palette[$color - 8];
		} else {
			// default color table
			if ($version == self::XLS_BIFF8) {
				return self::_mapColor($color);
			} else {
				// BIFF5
				return self::_mapColorBIFF5($color);
			}
		}

		return $color;
	}