Table of contents
Namespace: Com\Tecnick\Color
File: ComponentNormalizer.php line 35
Scales a parsed CSS component value into the [0..1] range used by the color models. Held as a collaborator by Css.
Tags
- since: 2026-08-26
- category: Library
- author: Nicola Asuni info@tecnick.com
- copyright: 2015-2026 Nicola Asuni - Tecnick.com LTD
- license: https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
- link: https://github.com/tecnickcom/tc-lib-color
Methods
normalize()
File: ComponentNormalizer.php line 50
public normalize(mixed $value, int $max) : float
A percentage string (e.g. ‘50%’) is divided by 100 and ignores $max; the ‘%’ must be the last character. Any other value is divided by $max. Non-numeric values, and any value passed with a non-positive $max, yield 0.0. The result is clamped to [0..1].
Parameters
- $value : mixed: Value to convert
- $max : int: Max input value (reference value), must be positive
Return values
float —
value [0..1]