Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401] [Versions 401 and 402] [Versions 401 and 403]

(no description)

File Size: 442 lines (14 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

Color:: (18 methods):
  __construct()
  getSharedComponent()
  getStyleArray()
  applyFromArray()
  validateColor()
  getARGB()
  setARGB()
  getRGB()
  setRGB()
  getColourComponent()
  getRed()
  getGreen()
  getBlue()
  changeBrightness()
  indexedColor()
  getHashCode()
  exportArray1()
  getHasChanged()


Class: Color  - X-Ref

__construct($colorValue = self::COLOR_BLACK, $isSupervisor = false, $isConditional = false)   X-Ref
Create a new Color.

param: string $colorValue ARGB value for the colour, or named colour
param: bool $isSupervisor Flag indicating if this is a supervisor or not
param: bool $isConditional Flag indicating if this is a conditional style or not

getSharedComponent()   X-Ref
Get the shared style component for the currently active cell in currently active sheet.
Only used for style supervisor.

return: Color

getStyleArray($array)   X-Ref
Build style array from subcomponents.

param: array $array
return: array

applyFromArray(array $styleArray)   X-Ref
Apply styles from array.

<code>
$spreadsheet->getActiveSheet()->getStyle('B2')->getFont()->getColor()->applyFromArray(['rgb' => '808080']);
</code>

param: array $styleArray Array containing style information
return: $this

validateColor(?string $colorValue)   X-Ref
No description

getARGB()   X-Ref
Get ARGB.


setARGB(?string $colorValue = self::COLOR_BLACK)   X-Ref
Set ARGB.

param: string $colorValue  ARGB value, or a named color
return: $this

getRGB()   X-Ref
Get RGB.


setRGB(?string $colorValue = self::COLOR_BLACK)   X-Ref
Set RGB.

param: string $colorValue RGB value, or a named color
return: $this

getColourComponent($rgbValue, $offset, $hex = true)   X-Ref
Get a specified colour component of an RGB value.

param: string $rgbValue The colour as an RGB value (e.g. FF00CCCC or CCDDEE
param: int $offset Position within the RGB value to extract
param: bool $hex Flag indicating whether the component should be returned as a hex or a
return: int|string The extracted colour component

getRed($rgbValue, $hex = true)   X-Ref
Get the red colour component of an RGB value.

param: string $rgbValue The colour as an RGB value (e.g. FF00CCCC or CCDDEE
param: bool $hex Flag indicating whether the component should be returned as a hex or a
return: int|string The red colour component

getGreen($rgbValue, $hex = true)   X-Ref
Get the green colour component of an RGB value.

param: string $rgbValue The colour as an RGB value (e.g. FF00CCCC or CCDDEE
param: bool $hex Flag indicating whether the component should be returned as a hex or a
return: int|string The green colour component

getBlue($rgbValue, $hex = true)   X-Ref
Get the blue colour component of an RGB value.

param: string $rgbValue The colour as an RGB value (e.g. FF00CCCC or CCDDEE
param: bool $hex Flag indicating whether the component should be returned as a hex or a
return: int|string The blue colour component

changeBrightness($hexColourValue, $adjustPercentage)   X-Ref
Adjust the brightness of a color.

param: string $hexColourValue The colour as an RGBA or RGB value (e.g. FF00CCCC or CCDDEE)
param: float $adjustPercentage The percentage by which to adjust the colour as a float from -1 to 1
return: string The adjusted colour as an RGBA or RGB value (e.g. FF00CCCC or CCDDEE)

indexedColor($colorIndex, $background = false, ?array $palette = null)   X-Ref
Get indexed color.

param: int $colorIndex Index entry point into the colour array
param: bool $background Flag to indicate whether default background or foreground colour

getHashCode()   X-Ref
Get hash code.

return: string Hash code

exportArray1()   X-Ref
No description

getHasChanged()   X-Ref
No description