Linear color gradient

@param float $value

@return string hex color
@internal
328314
public function getColorInRange($value)
    {
        $a = [54, 170, 31];
        $b = [220, 1, 57];
        [$min, $max] = $this->extremes;
        $d = $max - $min;
        $lin = ($value - $min) / ($d ?: 0.5); // prevent x/0
        $color = [];
        for ($i = 0; $i < 3; ++$i) {
            $color[$i] = (int) ($a[$i] + ($b[$i] - $a[$i]) * $lin);
        }

        return 'rgb(' . \implode(',', $color) . ')';
    }
1052670
private function styles(int $value) : string
    {
        $styles = '';

        if ($value > 0) {
            $styles .= ' width: ' . $value . '%;';
        }

        if ($this->height !== null && $this->height > 0) {
            $styles .= ' height:' . $this->height . 'px;';
        }

        return $styles;
    }
1066552
private function format_float($value) {
        if (is_numeric($value)) {
            if ($value > 0) {
                $decimals = strlen($value) - strlen(floor($value)) - 1;
            } else {
                $decimals = strlen($value) - strlen(ceil($value)) - 1;
            }
            $value = format_float($value, $decimals);
        }
        return $value;
    }
1035076
public static function materialRound(float $value)
    {
        if ($value > 999 && $value <= 999999) {
            return floor($value / 1000) . ' K';
        } elseif ($value > 999999) {
            return floor($value / 1000000) . ' M';
        }

        return $value;
    }
865593
public static function floatalize($value)
    {
        $value = strtoupper($value);
        if (strpos($value, 'E') === false) {
            return $value;
        }

        $number = substr($value, 0, strpos($value, 'E'));
        if (strpos($number, '.') !== false) {
            $post   = strlen(substr($number, strpos($number, '.') + 1));
            $mantis = substr($value, strpos($value, 'E') + 1);
            if ($mantis < 0) {
                $post += abs((int) $mantis);
            }

            $value = number_format($value, $post, '.', '');
        } else {
            $value = number_format($value, 0, '.', '');
        }

        return $value;
    }
1362359
public static function getReal($value)
    {
        $value     = (float)$value;
        $stringVal = (string)$value;
        if (!fmod($value, 1)) {
            $stringVal .= ".";
        }
        return $stringVal;
    }
118935
protected function getType($value)
    {
        if (is_object($value)) {
            return get_class($value);
        } else {
            return gettype($value) === 'double' ? 'float' : gettype($value);
        }
    }
87917
private static function stringify($value)
    {
        if (is_string($value)) {
            return sprintf('"%s"', preg_replace('/\n/', '\n', $value));
        }

        if (is_bool($value)) {
            return $value ? 'true' : 'false';
        }

        if (is_null($value)) {
            return 'null';
        }

        if (is_array($value)) {
            return sprintf('[%s]', implode(', ', array_map(
                function ($value) {
                    return self::stringify($value);
                },
                $value
            )));
        }

        return (string) $value;
    }
1255897
public function filter($value) : float
    {
        $float = $value;

        if ($value) {
            $float = str_replace(',', '.', $value);
        }

        return (float) $float;
    }
1288423
public function color($name = null, $value = null) 
	{
		Argument::i()
			->test(1, 'string', 'null')
			->test(2, 'string', 'null');
			
		$field = Color::i($name);
		
		if(!is_null($name)) {
			$field->setName($name);
		}
		
		if(!is_null($value)) {
			$field->setValue($value);
		}
		
		return $field;
	}
214249
protected function serializeScalar($value)
    {
        $type = \gettype($value);
        if ($type === 'double') {
            $type = 'float';
        }

        return [
            self::SCALAR_TYPE => $type,
            self::SCALAR_VALUE => $value,
        ];
    }
1304396
public static function load($value)
  {
    $value = trim($value);

    if (0 == strlen($value)) {
      return '';
    }

    if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) {
      $mbEncoding = mb_internal_encoding();
      mb_internal_encoding('ASCII');
    }

    switch ($value[0]) {
      case '[':
        $result = self::parseSequence($value);
        break;
      case '{':
        $result = self::parseMapping($value);
        break;
      default:
        $result = self::parseScalar($value);
    }

    if (isset($mbEncoding)) {
      mb_internal_encoding($mbEncoding);
    }

    return $result;
  }
267191
private function getValueType($value)
    {
        if (is_string($value))
            return 'string';
        if (is_bool($value))
            return 'bool';
        if (is_float($value))
            return 'float';
        if (is_numeric($value))
            return 'int';
        if (is_array($value))
            return 'array';
        return 'mixed';
    }
931738
public static function css_dimension( $value ) {

		// Trim it.
		$value = trim( $value );

		// If the value is round, then return 50%.
		if ( 'round' === $value ) {
			$value = '50%';
		}

		// If the value is empty, return empty.
		if ( '' === $value ) {
			return '';
		}

		// If auto, inherit or initial, return the value.
		if ( 'auto' === $value || 'initial' === $value || 'inherit' === $value || 'normal' === $value ) {
			return $value;
		}

		// Return empty if there are no numbers in the value.
		if ( ! preg_match( '#[0-9]#', $value ) ) {
			return '';
		}

		// If we're using calc() then return the value.
		if ( false !== strpos( $value, 'calc(' ) ) {
			return $value;
		}

		// The raw value without the units.
		$raw_value = self::filter_number( $value );
		$unit_used = '';

		// An array of all valid CSS units. Their order was carefully chosen for this evaluation, don't mix it up!!!
		$units = [ 'fr', 'rem', 'em', 'ex', '%', 'px', 'cm', 'mm', 'in', 'pt', 'pc', 'ch', 'vh', 'vw', 'vmin', 'vmax' ];
		foreach ( $units as $unit ) {
			if ( false !== strpos( $value, $unit ) ) {
				$unit_used = $unit;
			}
		}

		// Hack for rem values.
		if ( 'em' === $unit_used && false !== strpos( $value, 'rem' ) ) {
			$unit_used = 'rem';
		}

		return $raw_value . $unit_used;
	}
32136
protected function checkType($value)
    {
        if ($value === null) {
            return $value;
        }

        Type::force($value, 'numeric', true);
        return $value === null ? $value : (float)$value;
    }
637077
protected function coerceValue($value)
    {
        if (is_array($value) || $value instanceof \ArrayAccess) {
            return $value;
        }

        if (is_bool($value)) {
            return $this->toBool($value);
        }

        if ($value === null) {
            return static::$null;
        }

        if (is_numeric($value)) {
            return new Node\Number($value, '');
        }

        if ($value === '') {
            return static::$emptyString;
        }

        if (preg_match('/^(#([0-9a-f]{6})|#([0-9a-f]{3}))$/i', $value, $m)) {
            $color = [Type::T_COLOR];

            if (isset($m[3])) {
                $num = hexdec($m[3]);

                foreach ([3, 2, 1] as $i) {
                    $t = $num & 0xf;
                    $color[$i] = $t << 4 | $t;
                    $num >>= 4;
                }
            } else {
                $num = hexdec($m[2]);

                foreach ([3, 2, 1] as $i) {
                    $color[$i] = $num & 0xff;
                    $num >>= 8;
                }
            }

            return $color;
        }

        return [Type::T_KEYWORD, $value];
    }
610917
def linear_gradient(start_hex, finish_hex, n=10):
    
    s = hex2rgb(start_hex)
    f = hex2rgb(finish_hex)
    gradient = [s]
    for t in range(1, n):
        curr_vector = [int(s[j] + (float(t)/(n-1))*(f[j]-s[j])) for j in range(3)]
        gradient.append(curr_vector)
    return [rgb2hex([c/255. for c in rgb]) for rgb in gradient]