本文整理汇总了PHP中ImagickDraw::setfillcolor方法的典型用法代码示例。如果您正苦于以下问题:PHP ImagickDraw::setfillcolor方法的具体用法?PHP ImagickDraw::setfillcolor怎么用?PHP ImagickDraw::setfillcolor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImagickDraw
的用法示例。
在下文中一共展示了ImagickDraw::setfillcolor方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createAvatarAutomatically
/**
* アバター自動生成処理
*
* @param Model $model ビヘイビア呼び出し元モデル
* @param array $user ユーザデータ配列
* @return mixed On success Model::$data, false on failure
* @throws InternalErrorException
*/
public function createAvatarAutomatically(Model $model, $user)
{
//imagickdraw オブジェクトを作成します
$draw = new ImagickDraw();
//文字色のセット
$draw->setfillcolor('white');
//フォントサイズを 160 に設定します
$draw->setFontSize(140);
//テキストを追加します
$draw->setFont(CakePlugin::path($model->plugin) . 'webroot' . DS . 'fonts' . DS . 'ipaexg.ttf');
$draw->annotation(19, 143, mb_substr(mb_convert_kana($user['User']['handlename'], 'KVA'), 0, 1));
//新しいキャンバスオブジェクトを作成する
$canvas = new Imagick();
//ランダムで背景色を指定する
$red1 = strtolower(dechex(mt_rand(3, 12)));
$red2 = strtolower(dechex(mt_rand(0, 15)));
$green1 = strtolower(dechex(mt_rand(3, 12)));
$green2 = strtolower(dechex(mt_rand(0, 15)));
$blue1 = strtolower(dechex(mt_rand(3, 12)));
$blue2 = strtolower(dechex(mt_rand(0, 15)));
$canvas->newImage(179, 179, '#' . $red1 . $red2 . $green1 . $green2 . $blue1 . $blue2);
//ImagickDraw をキャンバス上に描画します
$canvas->drawImage($draw);
//フォーマットを PNG に設定します
$canvas->setImageFormat('png');
App::uses('TemporaryFolder', 'Files.Utility');
$folder = new TemporaryFolder();
$filePath = $folder->path . DS . Security::hash($user['User']['handlename'], 'md5') . '.png';
$canvas->writeImages($filePath, true);
return $filePath;
}
示例2: fill
public function fill($x1, $y1, $x2, $y2, $color = array(0, 0, 0, 100))
{
is_string($color) and $color = $this->create_hex_color($color);
if (is_array($color)) {
if (\Arr::is_assoc($color)) {
extract($color);
} else {
if (count($color) > 3) {
list($red, $green, $blue, $alpha) = $color;
} else {
list($red, $green, $blue) = $color;
$alpha = 100;
}
}
$alpha = round($alpha / 100, 1);
$color = new \ImagickPixel('rgba(' . $red . ', ' . $green . ', ' . $blue . ', ' . str_replace(',', '.', $alpha) . ')');
}
$fill = new \ImagickDraw();
$fill->setfillcolor($color);
$fill->rectangle($x1, $y1, $x2, $y2);
$this->imagick->drawimage($fill);
return $this;
}
示例3: fillCircle
/**
* Draw filled circle on current image
*
* @param string $color
* @param int $center_x
* @param int $center_y
* @param int $radius
* @param float $opacity
*
* @return image
*/
public function fillCircle($color, $center_x, $center_y, $radius, $opacity = 1)
{
$fill = new \ImagickDraw();
$fill->setfillcolor(new \ImagickPixel($color));
$fill->setfillopacity($opacity);
$fill->ellipse($center_x, $center_y, $radius, $radius, 0, 360);
$this->imagick->drawimage($fill);
return $this;
}
示例4: addWaterText
/**
*
* 文字水印
* @param unknown_type $data
*/
public function addWaterText($data)
{
$draw = new ImagickDraw();
$this->ImagickPixel = new ImagickPixel();
$draw->clear();
$draw->setfont($data['font']);
$draw->setfontsize($data['size']);
$this->ImagickPixel->setcolor($data['color']);
$draw->setfillcolor($data['color']);
$draw->setfillalpha($data['alpha']);
$draw->settextalignment(imagick::GRAVITY_NORTHWEST);
//左对齐
$draw->annotation($data['pos_x'], $data['pos_y'], $data['literal']);
$this->srcImg_source->drawimage($draw);
$draw->destroy();
return $this->srcImg_source;
}
示例5: switch
$maxX = $matches[4];
$maxY = $matches[5];
for ($x = $minX; $x <= $maxX; $x++) {
for ($y = $minY; $y <= $maxY; $y++) {
switch ($action) {
case 'turn on':
$grid[$x][$y] = true;
break;
case 'turn off':
$grid[$x][$y] = false;
break;
case 'toggle':
$grid[$x][$y] = !$grid[$x][$y];
}
}
}
}
}
$draw = new ImagickDraw();
$draw->setfillcolor(new ImagickPixel('white'));
foreach ($grid as $x => $col) {
foreach ($col as $y => $px) {
if ($px) {
$draw->color($x, $y, Imagick::PAINT_POINT);
}
}
}
$image = new Imagick();
$image->newimage(count($grid), count($grid[0]), 'black', 'png');
$image->drawimage($draw);
$image->writeimage('output.png');