From b9ffdc677a22339eba771bf136af4ccf2fa65e30 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Mon, 30 Oct 2017 12:50:37 +0100 Subject: [PATCH] Add rgb to int function --- Utils/ColorUtils.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Utils/ColorUtils.php b/Utils/ColorUtils.php index 443bd31f6..6e254cac3 100644 --- a/Utils/ColorUtils.php +++ b/Utils/ColorUtils.php @@ -46,4 +46,22 @@ class ColorUtils return $rgb; } + + /** + * Convert rgb to int + * + * @param array $rgb Int rgb array + * + * @return array + * + * @since 1.0.0 + */ + public static function rgbToInt(array $rgb) : int + { + $i = (255 & $rgb['r']) << 16; + $i += (255 & $rgb['g']) << 8; + $i += (255 & $rgb['b']); + + return $i; + } }