本文整理汇总了PHP中Rectangle::draw方法的典型用法代码示例。如果您正苦于以下问题:PHP Rectangle::draw方法的具体用法?PHP Rectangle::draw怎么用?PHP Rectangle::draw使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rectangle
的用法示例。
在下文中一共展示了Rectangle::draw方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: draw
{
public function draw()
{
print "Inside Rectangle::draw method.\n";
// 'print' works too
}
}
$we = new Employee('Bob', 'Diamond');
echo $we->greeting();
echo PHP_EOL;
$we->foo();
// overriding seems to work
$he->foo();
$rect = new Rectangle();
// or 'new Rectangle()'
$rect->draw();
echo empty("");
echo PHP_EOL;
echo null == NULL;
echo PHP_EOL;
// PHP Arrays are in fact associative arrays, i.e. Map and Dictionaries
$myArray = ["1" => "Hello", "2" => "How are you?", "3" => "Very well ty"];
$yourArray = [];
echo $myArray["1"] . PHP_EOL;
echo $myArray["2"] . PHP_EOL;
echo $myArray["3"] . PHP_EOL;
$myArray["4"] = "This is a new item";
echo $myArray["4"] . PHP_EOL;
echo $myArray["4"] . PHP_EOL;
var_dump($myArray);
$x = ["a", "b", "c"];
示例2: __construct
private $radius;
public function __construct($x, $y, $radius)
{
parent::__construct($x, $y);
$this->radius = $radius;
}
protected function drawShape()
{
return "Рисуем окружность с радиусом {$this->radius}";
}
}
class Rectangle extends Shape
{
private $width;
private $height;
public function __construct($x, $y, $width, $height)
{
parent::__construct($x, $y);
$this->width = $width;
$this->height = $height;
}
protected function drawShape()
{
return "Рисуем прямоугольник с шириной {$this->width} и высотой {$this->height}";
}
}
$circle = new Circle(0, 0, 50);
$rectangle = new Rectangle(0, 0, 100, 50);
$circle->draw();
$rectangle->draw();
示例3: draw
function draw($image)
{
$this->bound->normalize();
$depth = $this->depth;
if ($this->surfaces & self::SURFACE_BOTTOM) {
$points = [$this->bound->left(), $this->bound->bottom(), $this->bound->left() + $depth, $this->bound->bottom() - $depth, $this->bound->right() + $depth, $this->bound->bottom() - $depth, $this->bound->right(), $this->bound->bottom()];
imagefilledpolygon($image, $points, 4, $this->bgcolor->resolve($image));
if ($this->fgcolor !== NULL) {
imagepolygon($image, $points, 4, $this->fgcolor->resolve($image));
}
}
if ($this->surfaces & self::SURFACE_BACK) {
$points = [$this->bound->left() + $depth, $this->bound->bottom() - $depth, $this->bound->left() + $depth, $this->bound->top() - $depth, $this->bound->right() + $depth, $this->bound->top() - $depth, $this->bound->right() + $depth, $this->bound->bottom() - $depth];
imagefilledpolygon($image, $points, 4, $this->bgcolor->resolve($image));
if ($this->fgcolor !== NULL) {
imagepolygon($image, $points, 4, $this->fgcolor->resolve($image));
}
}
if ($this->surfaces & self::SURFACE_LEFT) {
$points = [$this->bound->left(), $this->bound->bottom(), $this->bound->left(), $this->bound->top(), $this->bound->left() + $depth, $this->bound->top() - $depth, $this->bound->left() + $depth, $this->bound->bottom() - $depth];
imagefilledpolygon($image, $points, 4, $this->bgcolor->resolve($image));
if ($this->fgcolor !== NULL) {
imagepolygon($image, $points, 4, $this->fgcolor->resolve($image));
}
}
if ($this->surfaces & self::SURFACE_RIGHT) {
$points = [$this->bound->right(), $this->bound->top(), $this->bound->right() + $depth, $this->bound->top() - $depth, $this->bound->right() + $depth, $this->bound->bottom() - $depth, $this->bound->right(), $this->bound->bottom()];
imagefilledpolygon($image, $points, 4, $this->bgcolor->resolve($image));
if ($this->fgcolor !== NULL) {
imagepolygon($image, $points, 4, $this->fgcolor->resolve($image));
}
}
if ($this->surfaces & self::SURFACE_TOP) {
$points = [$this->bound->left(), $this->bound->top(), $this->bound->left() + $depth, $this->bound->top() - $depth, $this->bound->right() + $depth, $this->bound->top() - $depth, $this->bound->right(), $this->bound->top()];
imagefilledpolygon($image, $points, 4, $this->bgcolor->resolve($image));
if ($this->fgcolor !== NULL) {
imagepolygon($image, $points, 4, $this->fgcolor->resolve($image));
}
}
if ($this->surfaces & self::SURFACE_FRONT) {
parent::draw($image);
}
}