public function colorAt($index) 
    {
        $sampleCount = $this->samples[$index * 5 + self::IDX_COUNT];
        $alphaSum = $this->samples[$index * 5 + self::IDX_A];
        return $sampleCount == 0 || $alphaSum == 0 ? 0 :
            ColorUtils::from(
                (int)($alphaSum / $sampleCount),
                (int)($this->samples[$index * 5 + self::IDX_R] / $alphaSum),
                (int)($this->samples[$index * 5 + self::IDX_G] / $alphaSum),
                (int)($this->samples[$index * 5 + self::IDX_B] / $alphaSum)
            );
    }