private static function getSuperSampleRanges(&$scanline, $width) 
    {
        $superSampleRanges = array();

        $rangeIndex = 0;
        $scanlineCount = count($scanline);

        while ($rangeIndex < $scanlineCount) {
            $range = $scanline[$rangeIndex];
            
            if ($range->fromX >= $width) {
                break;
            }
            
            $superSampleRange = new SuperSampleRange(
                $range->fromX,
                $range->fromX + $range->width
            );
            $superSampleRange->edges[] = $range->edge;
            
            $rangeIndex++;

            for ($i = $rangeIndex; $i < $scanlineCount; $i++) {
                $range = $scanline[$i];
                
                if ($range->fromX < $superSampleRange->toXExcl) {
                    $superSampleRange->toXExcl = max(
                        $superSampleRange->toXExcl, 
                        $range->fromX + $range->width);
                    $superSampleRange->edges[] = $range->edge;
                    $rangeIndex++;
                } else {
                    break;
                }
            }

            $superSampleRange->toXExcl = min($superSampleRange->toXExcl, $width);
            $superSampleRange->width = 
                $superSampleRange->toXExcl - $superSampleRange->fromX;
            
            $superSampleRanges[] = $superSampleRange;
        }

        return $superSampleRanges;
    }