ComponentNormalizer

Scales a parsed CSS component value into the [0..1] range used by the color models. Held as a collaborator by Css.

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

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]