略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: ImagickPixel::__construct

2024-12-22

ImagickPixel::__construct

(PECL imagick 2, PECL imagick 3)

ImagickPixel::__constructThe ImagickPixel constructor

说明

public ImagickPixel::__construct(string $color = ?)
警告

本函数还未编写文档,仅有参数列表。

Constructs an ImagickPixel object. If a color is specified, the object is constructed and then initialised with that color before being returned.

参数

color

The optional color string to use as the initial value of this object.

返回值

Returns an ImagickPixel object on success, throwing ImagickPixelException on failure.

范例

示例 #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($offsetX$offsetY40 $offsetX40 $offsetY);
        
$count++;
    }

    
$image = new \Imagick();
    
$image->newImage(350350"blue");
    
$image->setImageFormat("png");
    
$image->drawImage($draw);
    
header("Content-Type: image/png");
    echo 
$image->getImageBlob();
}

?>
add a noteadd a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/imagickpixel.construct.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3