 	func extendedSelection(around centerPoint: MatrixPoint, range: Range<Int> = 1..<2) -> [[Element]] {
 		var rings: [[Element]] = []
 		for ringIndex in range {
-			var ring: [Element] = []
 			
 			// Corners
 			let topLeft = MatrixPoint(row: centerPoint.row - ringIndex, column: centerPoint.column + ringIndex)


// extended selection

let rings = world.cells.extendedSelection(around: MatrixPoint(row: 5, column: 5))

var hue:  CGFloat = 0.5
var saturation: CGFloat = 0.8
let colorIncrement: CGFloat = 0.05
for (r, ring) in rings.enumerate() {
	for (i, cell) in ring.enumerate() {
		cell.color = NSColor(hue: hue, saturation: saturation, brightness: 0.8, alpha: 1.0)
	}
	hue += colorIncrement
	saturation -= colorIncrement
}

			let bottomLeft = MatrixPoint(row: centerPoint.row - ringIndex, column: centerPoint.column - ringIndex)
			
			// Edges
			let offset = 1
			let topRow: [Element] = elementsAt(column: topLeft.column, range: topLeft.row+offset..<bottomRight.row+offset)
			let rightColumn: [Element] = elementsAt(row: bottomRight.row, range: bottomRight.column..<topRight.column).reverse()
			let bottomRow: [Element] = elementsAt(column: bottomLeft.column, range: bottomLeft.row..<bottomRight.row).reverse()
			let leftColumn: [Element] = elementsAt(row: bottomLeft.row, range: bottomLeft.column+offset..<topLeft.column+offset)
			
			let ring: [Element] = topRow + rightColumn + bottomRow + leftColumn
			rings.append(ring)
		}
		return rings
	}
	
	public func spiral(from centerPoint: MatrixPoint, start cardinality: PrincipalCardinalDirection = .NorthWest, clockwise: Bool = true) -> AnyGenerator<Element> {

		var ringIndex = 1
		var elementIndex = 0
		var nextRing = extendedSelection(around: centerPoint).first!
		return AnyGenerator<Element> { 
			if elementIndex < nextRing.count {
				// Traverse each ring
				let element = nextRing[elementIndex]
				elementIndex += 1
				return element
			} else {
				// end of ring
				ringIndex += 1
				elementIndex = 0
				let nextRange = ringIndex..<ringIndex+1
				if let possibleNextRing = self.extendedSelection(around: centerPoint, range: nextRange).first where !possibleNextRing.isEmpty {
					nextRing = possibleNextRing
					let element = nextRing[0]
					return element
				} else {
					// All elements are out of bounds.
					return nil
				}
			}
		}
	}
}
