Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 39 and 311] [Versions 39 and 400] [Versions 39 and 401]

(no description)

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

Defines 1 class

Color:: (4 methods):
  rgb()
  throwIfInvalidColorComponentValue()
  convertColorComponentToHex()
  toARGB()


Class: Color  - X-Ref

Class Color
This class provides constants and functions to work with colors

rgb($red, $green, $blue)   X-Ref
Returns an RGB color from R, G and B values

param: int $red Red component, 0 - 255
param: int $green Green component, 0 - 255
param: int $blue Blue component, 0 - 255
return: string RGB color

throwIfInvalidColorComponentValue($colorComponent)   X-Ref
Throws an exception is the color component value is outside of bounds (0 - 255)

param: int $colorComponent
return: void

convertColorComponentToHex($colorComponent)   X-Ref
Converts the color component to its corresponding hexadecimal value

param: int $colorComponent Color component, 0 - 255
return: string Corresponding hexadecimal value, with a leading 0 if needed. E.g "0f", "2d"

toARGB($rgbColor)   X-Ref
Returns the ARGB color of the given RGB color,
assuming that alpha value is always 1.

param: string $rgbColor RGB color like "FF08B2"
return: string ARGB color