<?php

namespace smusatov\bzb2u;

use Imagick;

abstract class Render
{
    protected Label $label;

    public function __construct(Label $label)
    {
        $this->label = $label;
    }

    protected function makeJob(Imagick $im): Job{
        $job = new Job($this->label);
        $iterator = $im->getPixelIterator();
        foreach($iterator as $y => $row) {
            foreach($row as $x => $pixel) {
                $job->setPixel($x +1, $y +1, $pixel->getHSL()['luminosity'] <= 0.45);
            }
            $iterator->syncIterator();
        }

        return $job;
    }

    abstract public function render(): Job;

}
