本文整理汇总了PHP中Line::setLocation方法的典型用法代码示例。如果您正苦于以下问题:PHP Line::setLocation方法的具体用法?PHP Line::setLocation怎么用?PHP Line::setLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Line
的用法示例。
在下文中一共展示了Line::setLocation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rectangle
/**
* Draw a colored rectangle
*
* @param $color Rectangle color
* @param $line Rectangle diagonale
* @param $p2
*/
function rectangle($color, $line)
{
list($p1, $p2) = $line->getLocation();
// Get Red, Green, Blue and Alpha values for the line
list($r, $g, $b, $a) = $this->getColor($color);
// Calculate the coordinates of the two other points of the rectangle
$p3 = new Point($p1->x, $p2->y);
$p4 = new Point($p2->x, $p1->y);
$side = new Line($p1, $p2);
// Draw the four sides of the rectangle, clockwise
if ($p1->x <= $p2->x and $p1->y <= $p2->y or $p1->x >= $p2->x and $p1->y >= $p2->y) {
$side->setLocation($p1, $p4);
$this->line($color, $side);
$side->setLocation($p4, $p2);
$this->line($color, $side);
$side->setLocation($p2, $p3);
$this->line($color, $side);
$side->setLocation($p3, $p1);
$this->line($color, $side);
} else {
$side->setLocation($p1, $p3);
$this->line($color, $side);
$side->setLocation($p3, $p2);
$this->line($color, $side);
$side->setLocation($p2, $p4);
$this->line($color, $side);
$side->setLocation($p4, $p1);
$this->line($color, $side);
}
}
示例2: rectangle
function rectangle($color, $line) {
list($p1, $p2) = $line->getLocation();
switch($line->getStyle()) {
case LINE_SOLID :
$thickness = $line->getThickness();
$this->startThickness($thickness);
$rgb = $this->getColor($color);
imagerectangle($this->resource, $this->x + $p1->x, $this->y + $p1->y, $this->x + $p2->x, $this->y + $p2->y, $rgb);
$this->stopThickness($thickness);
break;
default :
$side = new Line($p1, $p2);
// Top side
$side->setLocation(
new awPoint($p1->x, $p1->y),
new awPoint($p2->x, $p1->y)
);
$this->line($color, $side);
// Right side
$side->setLocation(
new awPoint($p2->x, $p1->y),
new awPoint($p2->x, $p2->y)
);
$this->line($color, $side);
// Bottom side
$side->setLocation(
new awPoint($p1->x, $p2->y),
new awPoint($p2->x, $p2->y)
);
$this->line($color, $side);
// Left side
$side->setLocation(
new awPoint($p1->x, $p1->y),
new awPoint($p1->x, $p2->y)
);
$this->line($color, $side);
break;
}
}