Class: CIColor

Inherits:
NSObject show all

Overview

The CIColor class contains color values and the color space for which the color values are valid. You use CIColor objects in conjunction with other Core Image classes, such as CIFilter, CIContext,and CIImage, to take advantage of the built-in Core Image filters when processing images.

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from NSObject

#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, #init, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version

Constructor Details

This class inherits a constructor from NSObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class NSObject

Class Method Details

+ (CIColor) colorWithCGColor(c)

Creates a color object from a Quartz color. A CGColorRef object is the fundamental opaque data type used internally by Quartz to represent colors. For more information on Quartz 2D color and color spaces, see Quartz 2D Programming Guide.You can pass a CGColorRef object that represents any color space, including CMYK, but Core Image converts all color spaces to the Core Image working color space before it passes the color space to the filter kernel. The Core Image working color space uses three color components plus alpha.

Parameters:

  • c (CGColorRef)

    A Quartz color (CGColorRef object) created using a Quartz color creation function such as CGColorCreate.

Returns:

  • (CIColor)

    A Core Image color object that represents a Quartz color.

+ (CIColor) colorWithRed(r, green:g, blue:b)

Creates a color object using the specified RGB color component values

Parameters:

  • r (Float)

    The value of the red component.

  • g (Float)

    The value of the green component.

  • b (Float)

    The value of the blue component.

Returns:

  • (CIColor)

    A Core Image color object that represents an RGB color in the color space specified by the Quartz 2D constant kCGColorSpaceGenericRGB.

+ (CIColor) colorWithRed(r, green:g, blue:b, alpha:a)

Creates a color object using the specified RGBA color component values.

Parameters:

  • r (Float)

    The value of the red component.

  • g (Float)

    The value of the green component.

  • b (Float)

    The value of the blue component.

  • a (Float)

    The value of the alpha component.

Returns:

  • (CIColor)

    A Core Image color object that represents an RGB color in the color space specified by the Quartz 2D constant kCGColorSpaceGenericRGB and an alpha value.

+ (CIColor) colorWithString(representation)

Creates a color object using the RGBA color component values specified by a string.

Parameters:

  • representation (String)

    A string that is in one of the formats returned by the stringRepresentation method. For example, the string:@“0.5 0.7 0.3 1.0”indicates an RGB color whose components are 50% red, 70% green, 30% blue, and 100% opaque (alpha value of 1.0). The string representation always has four components—red, green, blue, and alpha. The default value for the alpha component is 1.0.

Returns:

  • (CIColor)

    A Core Image color object that represents an RGB color in the color space specified by the Quartz 2D constant kCGColorSpaceGenericRGB.

Instance Method Details

- (Float) alpha

Returns the alpha value of the color.

Returns:

  • (Float)

    The alpha value. A color created without an explicit alpha value has an alpha of 1.0 by default.

- (Float) blue

Returns the blue component of the color.

Returns:

  • (Float)

    The unpremultiplied blue component of the color.

- (CGColorSpaceRef) colorSpace

Returns the Quartz 2D color space associated with the color.

Returns:

  • (CGColorSpaceRef)

    The Quartz 2D color space (CGColorSpaceRef object). You are responsible for disposing of this color space by calling the Quartz 2D function CGColorSpaceRelease.

- (const CGFloat) components

Returns the color components of the color.

Returns:

  • (const CGFloat)

    An array of color components, specified as floating-point values in the range of 0.0 through 1.0. This array includes an alpha component if there is one.

- (Float) green

Returns the green component of the color.

Returns:

  • (Float)

    The unpremultiplied green component of the color.

- (Object) initWithCGColor(c)

Initializes a color object with a Quartz color. A CGColorRef object is the fundamental opaque data type used internally by Quartz to represent colors. For more information on Quartz 2D color and color spaces, see Quartz 2D Programming Guide.You can pass a CGColorRef object that represents any color space, including CMYK, but Core Image converts all color spaces to the Core Image working color space before it passes the color space to the filter kernel. The Core Image working color space uses three color components plus alpha.

Parameters:

  • c (CGColorRef)

    A Quartz color (CGColorRef) created using a Quartz color creation function such as CGColorCreate.

Returns:

- (size_t) numberOfComponents

Returns the number of color components in the color.

Returns:

  • (size_t)

    The number of color components, which includes an alpha component if there is one.

- (Float) red

Returns the red component of the color.

Returns:

  • (Float)

    The unpremultiplied red component of the color.

- (String) stringRepresentation

Returns a formatted string that specifies the components of the color. The string representation always has four components—red, green, blue, and alpha. The default value for the alpha component is 1.0.F or example, this string:@“0.5 0.7 0.3 1.0”indicates an RGB color whose components are 50% red, 70% green, 30% blue, and 100% opaque (alpha value of 1.0).

Returns:

  • (String)

    The formatted string.