             return RGBColorModel(red: Double(r) / 255, green: Double(g) / 255, blue: Double(b) / 255)
         }
         set {
-            self.r = UInt8(newValue.red * 255)
-            self.g = UInt8(newValue.green * 255)
-            self.b = UInt8(newValue.blue * 255)
+            self.r = UInt8((newValue.red * 255).clamped(to: 0...255))
+            self.g = UInt8((newValue.green * 255).clamped(to: 0...255))
+            self.b = UInt8((newValue.blue * 255).clamped(to: 0...255))
         }
     }
     public var alpha: Double {

    public var b: UInt8
    
    public init(color: RGBColorModel, alpha: Double) {
        self.a = UInt8(alpha * 255)
        self.r = UInt8(color.red * 255)
        self.g = UInt8(color.green * 255)
        self.b = UInt8(color.blue * 255)
    }
    
    public var color: RGBColorModel {

            return Double(a) / 255
        }
        set {
            self.a = UInt8((newValue * 255).clamped(to: 0...255))
        }
    }
}
