JansenFelipe\OMR\Scanners\ImagickScanner::topRight PHP Method

topRight() protected method

Most point to the top/right
protected topRight ( Point $near ) : Point
$near JansenFelipe\OMR\Point
return JansenFelipe\OMR\Point
    protected function topRight(Point $near)
    {
        $imagick = $this->getImagick();
        $first = new Point($near->getX() - 200, $near->getY() - 100);
        $last = new Point($near->getX() + 100, $near->getY() + 200);
        $point = new Point($first->getX(), $last->getY());
        //Add draw debug
        $this->draw->setStrokeOpacity(1);
        $this->draw->setFillOpacity(0);
        $this->draw->setStrokeWidth(2);
        $this->draw->setStrokeColor("#00CC00");
        $this->draw->rectangle($first->getX(), $first->getY(), $last->getX(), $last->getY());
        for ($y = $first->getY(); $y != $last->getY(); $y++) {
            for ($x = $first->getX(); $x != $last->getX(); $x++) {
                $color = $imagick->getImagePixelColor($x, $y)->getColor();
                if ($color['r'] <= 5 && $color['g'] <= 5 && $color['b'] <= 5) {
                    if ($x >= $point->getX()) {
                        $point->setX($x);
                    }
                    if ($y <= $point->getY()) {
                        $point->setY($y);
                    }
                }
            }
        }
        //Debug draw
        $this->draw->setFillColor("#00CC00");
        $this->draw->point($point->getX(), $point->getY());
        $this->debug();
        return $point;
    }