Библиотека для cis, online, cms1
This commit is contained in:
commit
3c2e614d87
269 changed files with 39854 additions and 0 deletions
13
core/geometry/point.php
Normal file
13
core/geometry/point.php
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
class Point
|
||||
{
|
||||
public $left, $top;
|
||||
function __construct ($left = 0, $top = 0)
|
||||
{
|
||||
$this->left = $left;
|
||||
$this->top = $top;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
53
core/geometry/rectangle.php
Normal file
53
core/geometry/rectangle.php
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
require_once "core/geometry/point.php";
|
||||
|
||||
class Rectangle
|
||||
{
|
||||
public $left, $top, $width, $height;
|
||||
|
||||
function __construct($left = 0, $top = 0, $width = 0, $height = 0)
|
||||
{
|
||||
$this->left = $left;
|
||||
$this->top = $top;
|
||||
$this->width = $width;
|
||||
$this->height = $height;
|
||||
}
|
||||
|
||||
function __get($name)
|
||||
{
|
||||
switch ($name) {
|
||||
case 'right': return $this->left + $this->width;
|
||||
case 'bottom': return $this->top + $this->height;
|
||||
}
|
||||
}
|
||||
|
||||
function __set($name, $value)
|
||||
{
|
||||
switch ($name) {
|
||||
case 'right': $this->width = $value - $this->left;
|
||||
case 'bottom': $this->height = $value - $this->top;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ñìåùàåò ïðÿìîóãîëüíèê íà çàäàííîå ïîëîæåíèå
|
||||
*/
|
||||
function addPoint(Point $point)
|
||||
{
|
||||
$result = clone $this;
|
||||
$result->left += $point->left;
|
||||
$result->top += $point->top;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Êîîðäèíàòû òî÷êè ïðè âûðàâíèâàíèè ïðÿìîóãîëüíèêà îòíîñèòåëüíî òåêóùåãî
|
||||
*/
|
||||
function alignment(Rectangle $base)
|
||||
{
|
||||
return new Point((($base->left + $base->right) - ($this->left + $this->right)) / 2, $base->bottom - $this->height);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue