Php/docs/imagickpixel.construct

提供:Dev Guides
< Php
移動先:案内検索

ImagickPixel::__construct

(PECL imagick 2, PECL imagick 3)

ImagickPixel::__constructImagickPixel のコンストラクタ


説明

public ImagickPixel::__construct ([ string $color ] )

警告 この関数は、 現在のところ詳細な情報はありません。引数のリストのみが 記述されています。


ImagickPixel オブジェクトを作成します。color を指定した場合は、 オブジェクトを作成した後で色を初期化してから返します。


パラメータ

color
このオブジェクトの初期化に使用する色を表すオプションの文字列。


返り値

成功した場合に ImagickPixel オブジェクトを返します。 失敗した場合に ImagickPixelException をスローします。


例1 ImagickPixel::construct()

<?phpfunction construct() {    $columns = 4;        $exampleColors = array(        "rgba(100%, 0%, 0%, 0.5)",        "hsb(33.3333%, 100%,  75%)", // medium green        "hsl(120, 255,   191.25)", //medium green        "graya(50%, 0.5)", //  semi-transparent mid gray        "LightCoral", "none", //"cmyk(0.9, 0.48, 0.83, 0.50)",        "#f00", //  #rgb        "#ff0000", //  #rrggbb        "#ff0000ff", //  #rrggbbaa        "#ffff00000000", //  #rrrrggggbbbb        "#ffff00000000ffff", //  #rrrrggggbbbbaaaa        "rgb(255, 0, 0)", //  an integer in the range 0—255 for each component        "rgb(100.0%, 0.0%, 0.0%)", //  a float in the range 0—100% for each component        "rgb(255, 0, 0)", //  range 0 - 255        "rgba(255, 0, 0, 1.0)", //  the same, with an explicit alpha value        "rgb(100%, 0%, 0%)", //  range 0.0% - 100.0%        "rgba(100%, 0%, 0%, 1.0)", //  the same, with an explicit alpha value    );    $draw = new \ImagickDraw();    $count = 0;    $black = new \ImagickPixel('rgb(0, 0, 0)');    foreach ($exampleColors as $exampleColor) {        $color = new \ImagickPixel($exampleColor);        $draw->setstrokewidth(1.0);        $draw->setStrokeColor($black);        $draw->setFillColor($color);        $offsetX = ($count % $columns) * 50 + 5;        $offsetY = intval($count / $columns) * 50 + 5;        $draw->rectangle(0 + $offsetX, 0 + $offsetY, 40 + $offsetX, 40 + $offsetY);        $count++;    }    $image = new \Imagick();    $image->newImage(350, 350, "blue");    $image->setImageFormat("png");    $image->drawImage($draw);    header("Content-Type: image/png");    echo $image->getImageBlob();}?>