         color.set()
         path.fill()
         
-//        NSGraphicsContext.restoreGraphicsState()
-        
-        image.unlockFocus()
-
-        image.lockFocus()
-        let imageRep = NSBitmapImageRep(focusedViewRect: NSMakeRect(0, 0, CGFloat(imageSize), CGFloat(imageSize)))
-        image.unlockFocus()
-            
-        return imageRep!
+        NSGraphicsContext.restoreGraphicsState()
+
+        return imageRep
     }
     
     func createTextureForBitmapImageRep(_ image: NSBitmapImageRep) -> MTLTexture

        let region = MTLRegionMake2D(0, 0, Int(image.size.width), Int(image.size.height))
        texture.replace(region: region, mipmapLevel: 0, slice: 0, withBytes: image.bitmapData!, bytesPerRow: image.bytesPerRow, bytesPerImage: image.bytesPerRow * Int(image.size.height))

//        var rect = NSMakeRect(0, 0, image.size.width, image.size.height)
//        let cgImage = image.cgImage(forProposedRect: &rect, context: nil, hints: nil)!
//        let loader = MTKTextureLoader(device: device)
//        let texture = try! loader.newTexture(with:cgImage, options: nil)
        
        return texture
    }


        a.isBlendingEnabled = true
        a.rgbBlendOperation = .add
        a.alphaBlendOperation = .add
        a.sourceRGBBlendFactor = .one
        a.sourceAlphaBlendFactor = .sourceAlpha
        a.destinationRGBBlendFactor = .oneMinusSourceColor
        a.destinationAlphaBlendFactor = .destinationAlpha
        pipelineState = try! device.makeRenderPipelineState(descriptor: pipelineStateDescriptor)

        commandQueue = device.makeCommandQueue()
