public void FromColorSpace() { var components = new nfloat [] { 0, 0.33f, 0.66f, 1 }; using var color = NSColor.FromColorSpace(NSColorSpace.GenericRGBColorSpace, components); color.GetComponents(out var actualComponents); Assert.AreEqual(components [0], actualComponents [0], "Red"); Assert.AreEqual(components [1], actualComponents [1], "Green"); Assert.AreEqual(components [2], actualComponents [2], "Blue"); Assert.AreEqual(components [3], actualComponents [3], "Alpha"); }
public static NSColor ToNS(this CGColor color) { if (color == null) { return(null); } if (MacVersion.IsAtLeast(10, 8)) { return(NSColor.FromCGColor(color)); } return(NSColor.FromColorSpace(new NSColorSpace(color.ColorSpace), color.Components)); }
public static NSColor ToNSColor(this Color value) { return(NSColor.FromColorSpace(NSColorSpace.SRGBColorSpace, new nfloat[] { value.R, value.G, value.B, value.A })); }