本文整理汇总了PHP中Line::apply方法的典型用法代码示例。如果您正苦于以下问题:PHP Line::apply方法的具体用法?PHP Line::apply怎么用?PHP Line::apply使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Line
的用法示例。
在下文中一共展示了Line::apply方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: apply
public function apply($resource)
{
// Get arguments
@(list(, $thickness, $color, $sides) = func_get_args());
$thickness = (int) $thickness;
if (!$color) {
$color = '#000000';
}
$sides = (int) $sides;
// Get resolution
$width = imagesx($resource);
$height = imagesy($resource);
if ($width === false || $height === false) {
throw new Exception("An error was encountered while getting image resolution");
}
// Define adjustment
$z = $thickness / 2;
// Draw borders
if ($sides == self::ALL || $sides == self::TOP) {
parent::apply($resource, 0, $z, $width, $z, $thickness, $color);
}
if ($sides == self::ALL || $sides == self::RIGHT) {
parent::apply($resource, $width - $z, $z, $width - $z, $height, $thickness, $color);
}
if ($sides == self::ALL || $sides == self::BOTTOM) {
parent::apply($resource, $width - $z, $height - $z, 0, $height - $z, $thickness, $color);
}
if ($sides == self::ALL || $sides == self::LEFT) {
parent::apply($resource, $z, $height, $z, 0, $thickness, $color);
}
return $resource;
}
示例2: apply
public function apply($resource)
{
// Extract arguments
@(list(, $direction, $step, $thickness, $color) = func_get_args());
$step = (int) $step;
$thickness = (int) $thickness;
if ($step < 2) {
$step = 2;
}
// Get resolution
$width = imagesx($resource);
$height = imagesy($resource);
if ($width === false || $height === false) {
throw new Exception("An error was encountered while getting image resolution");
}
// Apply effect
switch ($direction) {
case self::VERTICAL:
$x = 0;
while (($x += $step) < $width) {
parent::apply($resource, $x, 0, $x, $height, $thickness, $color);
}
break;
case self::HORIZONTAL:
default:
$y = 0;
while (($y += $step) < $height) {
parent::apply($resource, 0, $y, $width, $y, $thickness, $color);
}
}
return $resource;
}