1 // Copyright 2013 The Servo Project Developers. See the COPYRIGHT 2 // file at the top-level directory of this distribution. 3 // 4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or 5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license 6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your 7 // option. This file may not be copied, modified, or distributed 8 // except according to those terms. 9 10 use core_foundation::base::{CFTypeID}; 11 use base::CGFloat; 12 use core_foundation::base::TCFType; 13 use super::sys::{CGColorRef}; 14 15 pub use super::sys::CGColorRef as SysCGColorRef; 16 17 declare_TCFType!{ 18 CGColor, CGColorRef 19 } 20 impl_TCFType!(CGColor, CGColorRef, CGColorGetTypeID); 21 22 impl CGColor { rgb(red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat) -> Self23 pub fn rgb(red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat) -> Self { 24 unsafe { 25 let ptr = CGColorCreateGenericRGB(red, green, blue, alpha); 26 CGColor::wrap_under_create_rule(ptr) 27 } 28 } 29 } 30 31 #[link(name = "CoreGraphics", kind = "framework")] 32 extern { CGColorCreateGenericRGB(red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat) -> ::sys::CGColorRef33 fn CGColorCreateGenericRGB(red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat) -> ::sys::CGColorRef; CGColorGetTypeID() -> CFTypeID34 fn CGColorGetTypeID() -> CFTypeID; 35 } 36