]> _ Git - cubist_util.git/commitdiff
wip #6183 @0.25
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 28 Jul 2023 10:59:30 +0000 (12:59 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 28 Jul 2023 10:59:30 +0000 (12:59 +0200)
src/Graphics/Color.php

index d4ade5a3d8285902fbabc5709b95cbe4e0b3865d..5a377e5f502857a3d3764f1823e2826b2281cf75 100644 (file)
@@ -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;