sixty-nine/php-cloud-lib

View on GitHub
src/SixtyNine/Cloud/Placer/WordlePlacer.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

namespace SixtyNine\Cloud\Placer;

use Imagine\Image\Point;
use Imagine\Image\PointInterface;

class WordlePlacer extends AbstractPlacer
{
    protected $increment = 0;

    /** {@inheritdoc} */
    public function getNextPlaceToTry(PointInterface $current)
    {
        $i = $this->increment;
        $this->increment += 0.75;

        $x = $current->getX() + ($i / 2 * cos($i));
        $y = $current->getY() + ($i / 2 * sin($i));

        if ($x < 0 || $y < 0) {
            return false;
        }

        return new Point($x, $y);
    }
}