@param int $position_x1
@param int $position_y1
@param int $position_x2
@param int $position_y2

@return array
547428
public function getAverageColorInRegion(int $position_x1, int $position_y1, int $position_x2, int $position_y2): array
    {
        $this->check();

        $r = $g = $b = 0;

        for ($x = $position_x1; $x < $position_x2; ++$x) {
            for ($y = $position_y1; $y < $position_y2; ++$y) {
                $rgb = imagecolorat($this->image_resource, $x, $y);
                $r += ($rgb >> 16) & 0xFF;
                $g += ($rgb >> 8) & 0xFF;
                $b += $rgb & 0xFF;
            }
        }

        $so = ($position_x2 - $position_x1) * ($position_y2 - $position_y1);

        return [round($r / $so), round($g / $so), round($b / $so)];
    }
579037
public void set( double p1_x , double p1_y , double p2_x , double p2_y ) {
		this.p1.set(p1_x,p1_y);
		this.p2.set(p2_x,p2_y);
	}
234612
public function getByPosition($pos)
    {
        switch ($pos) {
            case 0:
                return $this->getId();
                break;
            case 1:
                return $this->getLocale();
                break;
            case 2:
                return $this->getLabel();
                break;
            default:
                return null;
                break;
        } // switch()
    }
368327
public function setPositionPosition($positionX, $positionY, $positionZ = null)
    {
        $this->setPositionProperty($this->positionProperties, $positionX, $positionY, $positionZ);
        return $this;
    }
1345606
protected function getRGB($x, $y) {
        $rgb = imagecolorat($this->image, $x, $y);

        return [
            'r' => ($rgb >> 16) & 0xFF,
            'g' => ($rgb >> 8) & 0xFF,
            'b' => $rgb & 0xFF
        ];
    }
60125
public static function moveArrayKeyToPos($key, $pos, $arr): array
    {
        if (!isset($arr[$key])) {
            return $arr;
        }

        $tempValue = $arr[$key];
        unset($arr[$key]);

        if ($pos === 0) {
            return [$key => $tempValue] + $arr;
        }

        if ($pos > \count($arr)) {
            return $arr + [$key => $tempValue];
        }

        $new_arr = [];
        $i = 1;

        foreach ($arr as $arr_key => $arr_value) {
            if ($i === $pos) {
                $new_arr[$key] = $tempValue;
            }

            $new_arr[$arr_key] = $arr_value;
            ++$i;
        }

        return $new_arr;
    }
744131
public function svgLine($x1, $y1, $x2, $y2)
    {
        // get the Closing operator
        $op='S';

        // drawing
        $this->_Point($x1, $y1, true);
        $this->_Line($x2, $y2, true);
        $this->_out($op);
    }
942814
public function getByPosition($position)
    {
        return isset($this->_entities[$position]) ? $this->_entities[$position] : null;
    }
207319
public static final function insert(array $Source, int $position, $value): array {
		return $position > 0 ? self::append(array_slice($Source, 0, $position), self::prepend(array_slice($Source,
			$position), self::cast($value))) : self::prepend($Source, self::cast($value));
	}
83252
public static function mergeNodes($items1, $items2)
    {
        $ret = array();
        $items = array_merge($items1, $items2);
        $len = count($items);

        // collects non-repeated elements
        for ($i = 0; $i < $len; $i++) {
            $item = $items[$i];
            $position = Dom::searchNode($item, $items, $i + 1);
            if ($position === false) {
                array_push($ret, $item);
            }
        }
        
        return $ret;
    }
975136
protected static function swap( &$array, $pos1, $pos2 )
	{
		if( isset( $array[$pos1] ) && isset( $array[$pos2] ) )
		{
			$memory	= $array[$pos1];
			$array[$pos1] = $array[$pos2];
			$array[$pos2] = $memory;
		}
	}
1312367
public function getLength($X1, $Y1, $X2, $Y2)
    {
        return sqrt(
            pow(max($X1, $X2) - min($X1, $X2), 2) + pow(max($Y1, $Y2) - min($Y1, $Y2), 2)
        );
    }
1012940
protected function getArray(Location $location): array
    {
        $properties = array_filter($location->toArray(), function ($value) {
            return !empty($value);
        });

        unset(
            $properties['latitude'],
            $properties['longitude'],
            $properties['bounds']
        );

        if (0 === count($properties)) {
            $properties = null;
        }

        $lat = 0;
        $lon = 0;
        if (null !== $coordinates = $location->getCoordinates()) {
            $lat = $coordinates->getLatitude();
            $lon = $coordinates->getLongitude();
        }

        $array = [
            'type' => 'Feature',
            'geometry' => [
                'type' => 'Point',
                'coordinates' => [$lon, $lat],
            ],
            'properties' => $properties,
        ];

        if (null !== $bounds = $location->getBounds()) {
            $array['bounds'] = $bounds->toArray();
        }

        return $array;
    }
1370996
public function hasChildren($position)
    {
        $item = $this->get($position);
        $relation = $item->getChildrenRelationIndex();

        return array_key_exists($relation, $item->getRelations());
    }
139848
function getAllNearPositions(position) {
    return [[-1, -1], [0, -1], [1, -1], [-1, 0], [1, 0], [-1, 1], [0, 1], [1, 1] // Below positions
    ].map(function (toAdd) {
        return {
            x: position.x + toAdd[0],
            y: position.y + toAdd[1]
        };
    });
}
741502
public static function findByPosition($position)
    {
        try {
            $offset = $position - 1;
            $tableName = self::getTableName();
            $conn = self::getConnection();

            $stmt = $conn->query('SELECT * FROM '.$tableName.' LIMIT '.$offset.', 1'); //mysql syntax
            if(! $stmt) {
                $stmt = $conn->query('SELECT * FROM '.$tableName.' OFFSET '.$offset.' LIMIT 1'); //pgsql syntax
            }

            return self::find($stmt);;
        }
        catch(PDOException $pe) {
            return $pe->getMessage();
        }
        catch(Exception $e) {
            return $e->getMessage();
        }
    }
63034
static public function getYandexCoordinatesByAdress($addressString)
    {
        if ($data = static::getYandexFirstFutureMemeber($addressString))
        {
            if ($coordinates = ArrayHelper::getValue($data, 'GeoObject.Point.pos'))
            {
                if ($coordinates)
                {
                    $data = explode(" ", $coordinates);
                    return [$data[1], $data[0]];
                }
            }
        }

        return [];
    }