From 114a461e886a59b44421fd138efda2726700258f Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Fri, 28 Jul 2023 12:59:30 +0200 Subject: [PATCH] wip #6183 @0.25 --- src/Graphics/Color.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Graphics/Color.php b/src/Graphics/Color.php index d4ade5a..5a377e5 100644 --- a/src/Graphics/Color.php +++ b/src/Graphics/Color.php @@ -150,6 +150,17 @@ class Color return 'rgba(' . self::_to255($this->_red) . ', ' . self::_to255($this->_green) . ', ' . self::_to255($this->_blue) . ', ' . $this->_alpha . ')'; } + /** + * @return float[] + */ + public function toLottie() + { + // Lottie colors are decimal numbers between 0 (0) and 1 (255) rounded at 12 digits + $digits = 12; + return [round($this->_red, $digits), round($this->_green, $digits), round($this->_blue, $digits), round($this->_alpha, $digits)]; + + } + public function toHexRVB() { return $this->toHexComposante('red') . $this->toHexComposante('green') . $this->toHexComposante('blue'); @@ -276,7 +287,6 @@ class Color */ public function distance(Color $color) { - return (30 * ($color->toIntComposante('red') - $this->toIntComposante('red'))) ** 2 + (59 * ($color->toIntComposante('green') - $this->toIntComposante('green'))) ** 2 + (11 * ($color->toIntComposante('blue') - $this->toIntComposante('blue'))) ** 2; -- 2.39.5