本文整理汇总了PHP中Intervention\Image\Image::pixel方法的典型用法代码示例。如果您正苦于以下问题:PHP Image::pixel方法的具体用法?PHP Image::pixel怎么用?PHP Image::pixel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Intervention\Image\Image
的用法示例。
在下文中一共展示了Image::pixel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mask
/**
* Apply given image as alpha mask on current image
*
* @param mixed $source
* @param boolean $mask_with_alpha
* @return Image
*/
public function mask($source, $mask_with_alpha = false)
{
// create new empty image
$maskedImage = new Image(null, $this->width, $this->height);
// create mask
$mask = is_a($source, 'Intervention\\Image\\Image') ? $source : new Image($source);
// resize mask to size of current image (if necessary)
if ($mask->width != $this->width || $mask->height != $this->height) {
$mask->resize($this->width, $this->height);
}
// redraw old image pixel by pixel considering alpha map
for ($x = 0; $x < $this->width; $x++) {
for ($y = 0; $y < $this->height; $y++) {
$color = $this->pickColor($x, $y, 'array');
$alpha = $mask->pickColor($x, $y, 'array');
if ($mask_with_alpha) {
$alpha = $alpha['a'];
// use alpha channel as mask
} else {
$alpha = floatval(round($alpha['r'] / 255, 2));
// use red channel as mask
}
// preserve alpha of original image...
if ($color['a'] < $alpha) {
$alpha = $color['a'];
}
$pixelColor = array($color['r'], $color['g'], $color['b'], $alpha);
$maskedImage->pixel($pixelColor, $x, $y);
}
}
// apply masked image to current instance
$this->resource = $maskedImage->resource;
$this->width = $maskedImage->width;
$this->height = $maskedImage->height;
return $this;
}
示例2: pixel
/**
* Set single pixel
*
* @param string $color
* @param integer $pos_x
* @param integer $pos_y
* @return \Intervention\Image\Image
* @static
*/
public static function pixel($color, $pos_x = 0, $pos_y = 0)
{
return \Intervention\Image\Image::pixel($color, $pos_x, $pos_y);
}