PHP 8.5.0 Beta 3 available for testing

ImagickPixel::__construct

(PECL imagick 2, PECL imagick 3)

ImagickPixel::__construct โ€” ImagickPixel ใฎใ‚ณใƒณใ‚นใƒˆใƒฉใ‚ฏใ‚ฟ

่ชฌๆ˜Ž

public ImagickPixel::__construct(string $color = ?)
่ญฆๅ‘Š

ใ“ใฎ้–ขๆ•ฐใฏใ€ ็พๅœจใฎใจใ“ใ‚่ฉณ็ดฐใชๆƒ…ๅ ฑใฏใ‚ใ‚Šใพใ›ใ‚“ใ€‚ๅผ•ๆ•ฐใฎใƒชใ‚นใƒˆใฎใฟใŒ ่จ˜่ฟฐใ•ใ‚Œใฆใ„ใพใ™ใ€‚

ImagickPixel ใ‚ชใƒ–ใ‚ธใ‚งใ‚ฏใƒˆใ‚’ไฝœๆˆใ—ใพใ™ใ€‚color ใ‚’ๆŒ‡ๅฎšใ—ใŸๅ ดๅˆใฏใ€ ใ‚ชใƒ–ใ‚ธใ‚งใ‚ฏใƒˆใ‚’ไฝœๆˆใ—ใŸๅพŒใง่‰ฒใ‚’ๅˆๆœŸๅŒ–ใ—ใฆใ‹ใ‚‰่ฟ”ใ—ใพใ™ใ€‚

ใƒ‘ใƒฉใƒกใƒผใ‚ฟ

color

ใ“ใฎใ‚ชใƒ–ใ‚ธใ‚งใ‚ฏใƒˆใฎๅˆๆœŸๅŒ–ใซไฝฟ็”จใ™ใ‚‹่‰ฒใ‚’่กจใ™ใ‚ชใƒ—ใ‚ทใƒงใƒณใฎๆ–‡ๅญ—ๅˆ—ใ€‚

ๆˆปใ‚Šๅ€ค

ๆˆๅŠŸใ—ใŸๅ ดๅˆใซ ImagickPixel ใ‚ชใƒ–ใ‚ธใ‚งใ‚ฏใƒˆใ‚’่ฟ”ใ—ใพใ™ใ€‚ ๅคฑๆ•—ใ—ใŸๅ ดๅˆใซ ImagickPixelException ใ‚’ใ‚นใƒญใƒผใ—ใพใ™ใ€‚

ไพ‹

ไพ‹1 ImagickPixel::construct()

<?php
function 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();
}

?>

๏ผ‹add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top