         generatedImage = nil
     }
 
-    func image() -> CGImage {
+    func image() -> CGImage? {
         if let image = generatedImage {
             return image
         }

                data.append(c)
            }
        }

        let colorSpace = CGColorSpaceCreateDeviceRGB()
        let bitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.premultipliedFirst.rawValue)

        let ctx = CGContext(data: &data, width: w, height: h, bitsPerComponent: bitsPerComponent, bytesPerRow: w * bytesPerPixel, space: colorSpace, bitmapInfo: bitmapInfo.rawValue)!
        ctx.interpolationQuality = .none
        ctx.setShouldAntialias(false)
        let img = ctx.makeImage()!
        generatedImage = img
        return img
    }

    private func pixelDataForGradient(at point: CGPoint,

        let h = Int(size.height * scale)
        let bitsPerComponent: Int = MemoryLayout<UInt8>.size * 8
        let bytesPerPixel: Int = bitsPerComponent * 4 / 8
        
        let colorSpace = CGColorSpaceCreateDeviceRGB()
        let bitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.premultipliedFirst.rawValue)
        
        var data = [ARGB]()

        for y in 0..<h {
