@param float $percentage

@return Color
512278
public function darken(float $percentage): Color
    {
        $colors      = $this->getHsl();
        $colors['l'] -= $colors['l'] * ($percentage / 100);

        $darkerColor = self::hslToRgb($colors['h'], $colors['s'], max(round($colors['l'], 5), 0));

        return new self(...array_values($darkerColor));
    }
861976
public static function success($percent, $htmlOptions = array())
    {
        ArrayHelper::addValue('class', Enum::COLOR_SUCCESS, $htmlOptions);
        return static::bar($percent, $htmlOptions);
    }
1167788
public static function percentage(float $n, int $precision = 0): string
    {
        return self::$locale->percent(round($n, $precision + 2));
    }
1100535
protected function _convertSubColor($c)
    {
        if (substr($c, -1)=='%') {
            $c = floatVal(substr($c, 0, -1))/100.;
        } else {
            $c = floatVal($c);
            if ($c>1) $c = $c/255.;
        }

        return $c;
    }
1315028
public function desaturate($percent)
    {
        $color = $this->toHsl();
        $saturation = $this->clamp(($color->saturation() - $percent) / 100);
        return $color->saturation($saturation * 100)->back($this);
    }
719417
public function scale($percent)
    {
        $this->mode = 'percentualScale';
        $this->targetSize = [$percent, null];
        $this->arguments = [];

        return $this->process();
    }
383014
def _percent_to_integer(percent):
    
    num = float(percent.split('%')[0]) / 100.0 * 255
    e = num - math.floor(num)
    return e < 0.5 and int(math.floor(num)) or int(math.ceil(num))
504361
public static function rgba( $hex, $percent ) {
		$hex = static::_hex_normalization( $hex );
		$rgba = [];

		for ( $i = 0; $i < 3; $i ++ ) {
			$dec = hexdec( substr( $hex, $i * 2, 2 ) );
			$rgba[] = $dec;
		}

		$rgba = implode( ',', $rgba );
		$rgba = "rgba({$rgba}, $percent)";

		return $rgba;
	}
63778
protected function percentualScale($width, $height, $percent)
    {
        $ratio  = $this->ratio($width, $height);
        $width  = (int)(round($width * $percent) / 100);
        $height = (int)floor($width / $ratio);

        return compact('width', 'height');

    }
1089227
public function calculatePercentage($decimal = 1)
    {
        // Profile not loaded yet.
        if (is_null($this->percentile)) {
            return null;
        }

        // Calculate percentage and return value
        return (float) number_format($this->percentile * 100, $decimal, '.', '');
    }
656242
public static String formatAsPercentage(int value, int total) {
        // value '1F' is to force floating conversion instead of loosing decimal part
        float average = total == 0 ? 0 : 1F * value / total;
        return PERCENT_FORMATTER.format(average);
    }
644287
protected static function modifyColor($rgbArr, $percent)
	{
		if (is_array($percent)) {
			foreach ($rgbArr as $i=>&$c) {
				$multiplier = $percent[$i] > 0 ? 1 + $percent[$i] / 100 : 1 - $percent[$i] / 100;
				$c = intval(round($c * $multiplier));
				if ($c > 255) $c = 255;
				if ($c < 0) $c = 0;
			}
		} else {
			$multiplier = $percent > 0 ? 1 + $percent / 100 : 1 - $percent / 100;
			foreach ($rgbArr as &$c) {
				$c = intval(round($c * $multiplier));
				if ($c > 255) $c = 255;
				if ($c < 0) $c = 0;
			}
		}

		return $rgbArr;
	}
1190763
private function getPercentage(int $count, int $total): string
    {
        return ($total !== 0) ? I18N::percentage($count / $total, 1) : '';
    }
544341
public function format($value): string
    {
        if ($value instanceof Percentage) {
            $value = $value->toPercent();
        }

        return $value->int().'%';
    }
946695
public static String percentageBar(double percentage) {
        final char  dot   = '.';
        final char  mark  = '#';
        final int   slots = 40;

        StringBuilder bar = new StringBuilder(replicate(String.valueOf(dot), slots));
        int numSlots = (int) (slots * percentage / 100.0);
        for (int k = 0; k < numSlots; ++k) bar.setCharAt(k, mark);

        return String.format("[%s] %3.0f%%", bar, percentage);
    }
1014994
public Color getColorAt(final float FRACTION) {
        float fraction = FRACTION < 0f ? 0f : (FRACTION > 1f ? 1f : FRACTION);
        float lowerLimit = 0f;
        int lowerIndex = 0;
        float upperLimit = 1f;
        int upperIndex = 1;
        int index = 0;

        for (float currentFraction : fractions) {
            if (Float.compare(currentFraction, fraction) < 0) {
                lowerLimit = currentFraction;
                lowerIndex = index;
            }
            if (Float.compare(currentFraction, fraction) == 0) {
                return colors[index];
            }
            if (Float.compare(currentFraction, fraction) > 0) {
                upperLimit = currentFraction;
                upperIndex = index;
                break;
            }
            index++;
        }

        float interpolationFraction = (fraction - lowerLimit) / (upperLimit - lowerLimit);

        return interpolateColor(colors[lowerIndex], colors[upperIndex], interpolationFraction);
    }
1156164
def percent(self, value) -> 'Gap':
        """"""
        raise_not_number(value)
        self.gap = '{}%'.format(value)
        return self