Files
swift-mirror/test/Interpreter/SDK/cf_extensions.swift
Chris Willmore 98d17e318d Add support for AppleTV simulator tests.
You can run tests with e.g. 'ninja check-swift-appletvsimulator-x86_64'.

Swift SVN r27297
2015-04-14 23:53:03 +00:00

42 lines
847 B
Swift

// RUN: %target-run-simple-swift | FileCheck %s
// REQUIRES: objc_interop
import Foundation
#if os(OSX)
import AppKit
#endif
#if os(iOS) || os(tvOS)
import UIKit
#endif
extension CGColorSpace {
class func deviceRGB() -> CGColorSpace {
return CGColorSpaceCreateDeviceRGB()
}
}
extension CGColor {
class func create(#colorSpace: CGColorSpace, #components: [CGFloat])
-> CGColor {
return CGColorCreate(colorSpace, components)
}
var r: CGFloat { return CGColorGetComponents(self)[0] }
var g: CGFloat { return CGColorGetComponents(self)[1] }
var b: CGFloat { return CGColorGetComponents(self)[2] }
}
let pink = CGColor.create(colorSpace: .deviceRGB(),
components: [1.0, 0.5, 0.25, 1.0])
// CHECK: 1.0
println(pink.r)
// CHECK-NEXT: 0.5
println(pink.g)
// CHECK-NEXT: 0.25
println(pink.b)