Exemplo n.º 1
0
        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");
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
 public static NSColor ToNSColor(this Color value)
 {
     return(NSColor.FromColorSpace(NSColorSpace.SRGBColorSpace, new nfloat[] { value.R, value.G, value.B, value.A }));
 }