import Foundation extension Array where Element == ColorGradient { /// <#Description#> /// - Parameter index: offset in data table /// - Returns: <#description#> func rotate(for index: Int) -> ColorGradient { if self.isEmpty { return ColorGradient.orangeBright } if self.count <= index { return self[index % self.count] } return self[index] } } extension Collection { /// Returns the element at the specified index if it is within bounds, otherwise nil. subscript (safe index: Index) -> Element? { return indices.contains(index) ? self[index] : nil } }