Kirki_Color::rgba2hex PHP Метод

rgba2hex() публичный статический Метод

A proxy for the sanitize_color method.
public static rgba2hex ( string | array $color ) : string
$color string | array The color to convert.
Результат string The hex value of the color.
        public static function rgba2hex($color)
        {
            return self::sanitize_color($color, 'hex');
        }

Usage Example

Пример #1
0
 public function test_rgba2hex()
 {
     /**
      * White
      */
     $this->assertEquals('#ffffff', Kirki_Color::rgba2hex('rgba(255,255,255,1)'));
     $this->assertEquals('#ffffff', Kirki_Color::rgba2hex('rgba(255,255,255,0)'));
     $this->assertEquals('#ffffff', Kirki_Color::rgba2hex('rgba( 255, 255, 255, 0 ) '));
     $this->assertEquals(true, '#ffffff' != Kirki_Color::rgba2hex('rgba(255,230,255,1)'));
     /**
      * Black
      */
     $this->assertEquals('#000000', Kirki_Color::rgba2hex('rgba(0,0,0,1)'));
     $this->assertEquals('#000000', Kirki_Color::rgba2hex('rgba( 0, 0, 0, 1)'));
     $this->assertEquals(true, '#000000' != Kirki_Color::rgba2hex('rgba(0,0,0,.1)'));
     /**
      * Opacity
      */
     $this->assertEquals('#7f7f7f', Kirki_Color::rgba2hex('rgba(0,0,0,.5)'));
     $this->assertEquals('#ff7f7f', Kirki_Color::rgba2hex('rgba(255,0,0,.5)'));
     $this->assertEquals('#7fff7f', Kirki_Color::rgba2hex('rgba(0,255,0,.5)'));
     $this->assertEquals('#7f7fff', Kirki_Color::rgba2hex('rgba(0,0,255,.5)'));
     /**
      * invalid
      */
     $this->assertEquals('#ffffff', Kirki_Color::rgba2hex('rgba(0,.5)'));
     $this->assertEquals('#ffffff', Kirki_Color::rgba2hex('#ffffff'));
 }
All Usage Examples Of Kirki_Color::rgba2hex