Nextcloud PHP API (master)

Color
in package

Simple RGB color container

Tags
since
25.0.0

Table of Contents

Properties

$b  : int
$g  : int
$r  : int

Methods

__construct()  : mixed
alphaBlending()  : Color
Blend this color over a source color.
blue()  : int
Returns the blue color component of this color as an int from 0 to 255
blueF()  : float
Returns the blue color component of this color as a float from 0 to 1
green()  : int
Returns the green color component of this color as an int from 0 to 255
greenF()  : float
Returns the green color component of this color as a float from 0 to 1
mixPalette()  : array<int, Color>
Generate a progression of colors starting with $color1 and moving toward $color2.
name()  : string
Returns the hex triplet color value as a string ("#RRGGBB")
red()  : int
Returns the red color component of this color as an int from 0 to 255
redF()  : float
Returns the red color component of this color as a float from 0 to 1
assertChannelInRange()  : void
calculateDeltas()  : array{0: float, 1: float, 2: float}
Calculate the per-channel change (RGB deltas) required to transition between two colors.

Properties

Methods

__construct()

public __construct(int $r, int $g, int $b) : mixed
Parameters
$r : int
$g : int
$b : int
Tags
since
25.0.0

alphaBlending()

Blend this color over a source color.

public alphaBlending(float $opacity, Color $source) : Color

An opacity of 0 returns $source, and 1 returns this color.

Parameters
$opacity : float

Opacity of this color, expected in the range 0.0 to 1.0

$source : Color

The source/background color

Tags
since
25.0.0
Return values
Color —

The blended color

blue()

Returns the blue color component of this color as an int from 0 to 255

public blue() : int
Tags
since
25.0.0
Return values
int

blueF()

Returns the blue color component of this color as a float from 0 to 1

public blueF() : float
Tags
since
25.0.0
Return values
float

green()

Returns the green color component of this color as an int from 0 to 255

public green() : int
Tags
since
25.0.0
Return values
int

greenF()

Returns the green color component of this color as a float from 0 to 1

public greenF() : float
Tags
since
25.0.0
Return values
float

mixPalette()

Generate a progression of colors starting with $color1 and moving toward $color2.

public static mixPalette(int $steps, Color $color1, Color $color2) : array<int, Color>
Parameters
$steps : int

Total number of colors to return (including $color1, but excluding $color2); should be at least 2

$color1 : Color

The starting color (index 0 of the returned list)

$color2 : Color

The target color used to calculate the transition

Tags
since
25.0.0
Return values
array<int, Color> —

The list of colors starting with $color1 up to but not including $color2

name()

Returns the hex triplet color value as a string ("#RRGGBB")

public name() : string
Tags
since
25.0.0
Return values
string

red()

Returns the red color component of this color as an int from 0 to 255

public red() : int
Tags
since
25.0.0
Return values
int

redF()

Returns the red color component of this color as a float from 0 to 1

public redF() : float
Tags
since
25.0.0
Return values
float

assertChannelInRange()

private static assertChannelInRange(int $value, string $channel) : void
Parameters
$value : int
$channel : string

calculateDeltas()

Calculate the per-channel change (RGB deltas) required to transition between two colors.

private static calculateDeltas(int $count, Color $start, Color $end) : array{0: float, 1: float, 2: float}
Parameters
$count : int

The number of intervals to divide the transition into >0

$start : Color

The starting color

$end : Color

The target color

Tags
since
25.0.0
Return values
array{0: float, 1: float, 2: float} —

The per-channel [r, g, b] increment required for each interval

On this page

Search results