Skip to content

classes_base_color.class

Daniel Spors edited this page Dec 19, 2023 · 3 revisions

Classes in file base/color.class.php

class Color

Helper class to deal with HTML colors.

hex

Composes a Color object from a valid HTML color string.

Definition: public static function hex($hex_string)

Returns: Color

Parameters:

  • string $hex_string Valid HTML color string

matchingFont

Returns 'white' or 'black', which ever will be better readable if the given color is a background.

Definition: public static function matchingFont(Color $c, $swapvalue)

Returns: Color Black or White

Parameters:

  • Color $c The background color

  • int $swapvalue Value when the default 'black' is replaced by 'white' (default: 100)

random

Composes a random Color.

Definition: public static function random($min=false, $max=false)

Returns: \ScavixWDF\Base\Color

Parameters:

  • mixed $min Optional string or Color defining the minimum

  • mixed $max Optional string or Color defining the maximum

range

Composes a ColorRange object.

Definition: public static function range($from, $to)

Returns: \ScavixWDF\Base\Color\ColorRange

Parameters:

  • mixed $from Optional string or Color defining the start

  • mixed $to Optional string or Color defining the end

rgba

Composes a Color object from RGBA values.

Definition: public static function rgba($r, $g, $b, $a)

Returns: \ScavixWDF\Base\Color

Parameters:

  • int $r Red component (0-255)

  • int $g Green component (0-255)

  • int $b Blue component (0-255)

  • float $a Alpha (0-1)

setAlpha

Sets the alpha value of the color.

Definition: public function setAlpha($a)

Returns: static

Parameters:

  • float|string $a Alpha value as float (0..1) or string (00..FF)

class ColorRange

Represents a color range. Never construct a ColorRange directly, but use Color::range, otherwise the classloader may fail.

fromPercent

Return the color corresponding to percent in the range.

Definition: public function fromPercent($percent)

Returns: \ScavixWDF\Base\Color

Parameters:

  • float|int $percent The percent (0-100) to get the color for

fromValue

Return the color corresponding to a value in the range.

Definition: public function fromValue($value)

Returns: \ScavixWDF\Base\Color

Parameters:

  • float|int $value The value (between min and max) to get the color for

setMinMax

Sets values that act as min and max when querying data.

Definition: public function setMinMax($min, $max)

Returns: ColorRange $this

Parameters:

  • float|int $min Minimum value

  • float|int $max Maximum value

Clone this wiki locally