Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test functions

generateConsistentColour()

Description

Generate a consistent HSL-based colour with a fixed brightness and saturation, but a random hue.

This function hashes the input key (e.g., plugin name) to determine the hue,
while keeping the saturation and brightness fixed. The generated colour is
converted to a CSS hex colour code.

Parameters

ColumnTypeDefaultDescription
$key string The input string (e.g., plugin name) to generate a colour for.
$saturation int 70 The saturation percentage (0-100). Default is 70.
$lightness int 50 The lightness percentage (0-100). Default is 50.

Return

string The generated CSS hex colour code (e.g., #ff5733).

This article was last updated 8th December 2024 20:35 Europe/London time based on the source file dated 6th December 2024 11:00 Europe/London time.