Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

(no description)

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

Defines 1 class

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


Class: Color  - X-Ref

This class provides constants and functions to work with colors.

rgb(int $red, int $green, int $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

toARGB(string $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

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


convertColorComponentToHex(int $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"