/** * @covers ColorThief\VBox::longestAxis */ public function testLongestAxis() { $this->vbox->r1 = 225 >> ColorThief::RSHIFT; $this->vbox->r2 = 247 >> ColorThief::RSHIFT; $this->vbox->g1 = 180 >> ColorThief::RSHIFT; $this->vbox->g2 = 189 >> ColorThief::RSHIFT; $this->vbox->b1 = 180 >> ColorThief::RSHIFT; $this->vbox->b2 = 228 >> ColorThief::RSHIFT; $this->assertEquals('b', $this->vbox->longestAxis()); $this->vbox->g1 = 110 >> ColorThief::RSHIFT; $this->assertEquals('g', $this->vbox->longestAxis()); $this->vbox->r1 = 10 >> ColorThief::RSHIFT; $this->assertEquals('r', $this->vbox->longestAxis()); }
/** * @param array $histo * @param VBox $vBox * @return array|void */ private static function medianCutApply($histo, $vBox) { if (!$vBox->count()) { return; } // If the vbox occupies just one element in color space, it can't be split if ($vBox->count() == 1) { return array($vBox->copy()); } // Select the longest axis for splitting $cutColor = $vBox->longestAxis(); // Find the partial sum arrays along the selected axis. list($total, $partialSum) = static::sumColors($cutColor, $histo, $vBox); return static::doCut($cutColor, $vBox, $partialSum, $total); }