iOS Developer Library

Developer

Core Image Reference Collection CIVector Class Reference

Options
Deployment Target:

On This Page
Language:

CIVector

The CIVector class is used for coordinate values and direction vectors. You typically use a CIVector object to pass parameter values to Core Image filters. CIVector objects work in conjunction with other Core Image classes, such as CIFilter, CIContext, CIImage, and CIColor, to process images using the Core Image framework.

  • Creates and returns a vector that is initialized with the specified values.

    Declaration

    Objective-C

    + (instancetype)vectorWithValues:(const CGFloat *)values count:(size_t)count

    Parameters

    values

    The values to initialize the vector with.

    count

    The number of values in the vector.

    Return Value

    A vector initialized with the provided values.

    Availability

    Available in iOS 5.0 and later.

  • Creates and returns a vector that is initialized with one value.

    Declaration

    Objective-C

    + (instancetype)vectorWithX:(CGFloat)x

    Parameters

    x

    The value to initialize the vector with.

    Return Value

    A vector initialized with the specified value.

    Availability

    Available in iOS 5.0 and later.

  • Creates and returns a vector that is initialized with two values.

    Declaration

    Objective-C

    + (instancetype)vectorWithX:(CGFloat)x Y:(CGFloat)y

    Parameters

    x

    The value for the first position in the vector.

    y

    The value for the second position in the vector.

    Return Value

    A vector initialized with the specified values.

    Availability

    Available in iOS 5.0 and later.

  • Creates and returns a vector that is initialized with three values.

    Declaration

    Objective-C

    + (instancetype)vectorWithX:(CGFloat)x Y:(CGFloat)y Z:(CGFloat)z

    Parameters

    x

    The value for the first position in the vector.

    y

    The value for the second position in the vector.

    z

    The value for the third position in the vector.

    Return Value

    A vector initialized with the specified values.

    Availability

    Available in iOS 5.0 and later.

  • Creates and returns a vector that is initialized with four values.

    Declaration

    Objective-C

    + (instancetype)vectorWithX:(CGFloat)x Y:(CGFloat)y Z:(CGFloat)z W:(CGFloat)w

    Parameters

    x

    The value for the first position in the vector.

    y

    The value for the second position in the vector.

    z

    The value for the third position in the vector.

    w

    The value for the fourth position in the vector.

    Return Value

    A vector initialized with the specified values.

    Availability

    Available in iOS 5.0 and later.

  • Creates and returns a vector that is initialized with values provided in a string representation.

    Declaration

    Objective-C

    + (instancetype)vectorWithString:(NSString *)representation

    Parameters

    representation

    A string that is in one of the formats returned by the stringRepresentation method.

    Discussion

    Some typical string representations for vectors are:

    @"[1.0 0.5 0.3]"

    which specifies a vec3 vector whose components are X = 1.0, Y = 0.5, and Z = 0.3

    @"[10.0 23.0]

    which specifies a vec2 vector show components are X = 10.0 and Y = 23.0

    Availability

    Available in iOS 5.0 and later.

  • Creates and returns a vector that is initialized with values provided by a CGAffineTransform structure.

    Declaration

    Objective-C

    + (instancetype)vectorWithCGAffineTransform:(CGAffineTransform)t

    Parameters

    t

    A transform.

    Return Value

    A vector initialized with the specified values.

    Discussion

    The six values that comprise the affine transform fill the first six positions of the resulting CIVector object.

    Availability

    Available in iOS 5.0 and later.

  • Creates and returns a vector that is initialized with values provided by a CGPoint structure.

    Declaration

    Objective-C

    + (instancetype)vectorWithCGPoint:(CGPoint)p

    Parameters

    p

    A point.

    Return Value

    A vector initialized with the specified values.

    Discussion

    The CGPoint structure’s X and Y values are stored in the vector’s X and Y properties.

    Availability

    Available in iOS 5.0 and later.

  • Creates and returns a vector that is initialized with values provided by a CGRect structure.

    Declaration

    Objective-C

    + (instancetype)vectorWithCGRect:(CGRect)r

    Parameters

    r

    A rect.

    Return Value

    A vector initialized with the specified values.

    Discussion

    The CGRect structure’s X, Y, height and width values are stored in the vector’s X, Y, Z and W properties.

    Availability

    Available in iOS 5.0 and later.

  • Initializes a vector with the provided values.

    Declaration

    Swift

    init(values values: UnsafePointer<CGFloat>, count count: Int)

    Objective-C

    - (instancetype)initWithValues:(const CGFloat *)values count:(size_t)count

    Parameters

    values

    The values to initialize the vector with.

    count

    The number of values specified by the values argument.

    Availability

    Available in iOS 5.0 and later.

  • Initializes the first position of a vector with the provided values.

    Declaration

    Swift

    convenience init(x x: CGFloat)

    Objective-C

    - (instancetype)initWithX:(CGFloat)x

    Parameters

    x

    The initialization value.

    Availability

    Available in iOS 5.0 and later.

  • Initializes the first two positions of a vector with the provided values.

    Declaration

    Swift

    convenience init(x x: CGFloat, y y: CGFloat)

    Objective-C

    - (instancetype)initWithX:(CGFloat)x Y:(CGFloat)y

    Parameters

    x

    The initialization value for the first position.

    y

    The initialization value for the second position.

    Availability

    Available in iOS 5.0 and later.

  • Initializes the first three positions of a vector with the provided values.

    Declaration

    Swift

    convenience init(x x: CGFloat, y y: CGFloat, z z: CGFloat)

    Objective-C

    - (instancetype)initWithX:(CGFloat)x Y:(CGFloat)y Z:(CGFloat)z

    Parameters

    x

    The initialization value for the first position.

    y

    The initialization value for the second position.

    z

    The initialization value for the third position.

    Availability

    Available in iOS 5.0 and later.

  • Initializes four positions of a vector with the provided values.

    Declaration

    Swift

    convenience init(x x: CGFloat, y y: CGFloat, z z: CGFloat, w w: CGFloat)

    Objective-C

    - (instancetype)initWithX:(CGFloat)x Y:(CGFloat)y Z:(CGFloat)z W:(CGFloat)w

    Parameters

    x

    The initialization value for the first position.

    y

    The initialization value for the second position.

    z

    The initialization value for the third position.

    w

    The initialization value for the fourth position.

    Availability

    Available in iOS 5.0 and later.

  • Initializes a vector with values provided in a string representation.

    Declaration

    Swift

    convenience init(string representation: String)

    Objective-C

    - (instancetype)initWithString:(NSString *)representation

    Parameters

    representation

    A string that is in one of the formats returned by the stringRepresentation method.

    Availability

    Available in iOS 5.0 and later.

  • Initializes a vector that is initialized with values provided by a CGAffineTransform structure.

    Declaration

    Swift

    convenience init(CGAffineTransform r: CGAffineTransform)

    Objective-C

    - (instancetype)initWithCGAffineTransform:(CGAffineTransform)r

    Parameters

    r

    A transform.

    Discussion

    The six values that comprise the affine transform fill the first six positions of the resulting CIVector object.

    Availability

    Available in iOS 5.0 and later.

  • Initializes a vector that is initialized with values provided by a CGPoint structure.

    Declaration

    Swift

    convenience init(CGPoint p: CGPoint)

    Objective-C

    - (instancetype)initWithCGPoint:(CGPoint)p

    Parameters

    p

    A point.

    Discussion

    The CGPoint structure’s X and Y values are stored in the vector’s X and Y properties.

    Availability

    Available in iOS 5.0 and later.

  • Initializes a vector that is initialized with values provided by a CGRect structure.

    Declaration

    Swift

    convenience init(CGRect r: CGRect)

    Objective-C

    - (instancetype)initWithCGRect:(CGRect)r

    Parameters

    r

    A rect.

    Discussion

    The CGRect structure’s X, Y, height and width values are stored in the vector’s X, Y, Z and W properties.

    Availability

    Available in iOS 5.0 and later.

  • Returns a value from a specific position in the vector.

    Declaration

    Swift

    func valueAtIndex(_ index: Int) -> CGFloat

    Objective-C

    - (CGFloat)valueAtIndex:(size_t)index

    Parameters

    index

    The position in the vector of the value that you want to retrieve.

    Return Value

    The value retrieved from the vector or 0 if the position is undefined.

    Discussion

    The numbering of elements in a vector begins with zero.

    Availability

    Available in iOS 5.0 and later.

  • The number of items in the vector. (read-only)

    Declaration

    Swift

    var count: Int { get }

    Objective-C

    @property(readonly) size_t count

    Availability

    Available in iOS 5.0 and later.

  • X X Property

    The value located in the first position in the vector. (read-only)

    Declaration

    Swift

    var X: CGFloat { get }

    Objective-C

    @property(readonly) CGFloat X

    Availability

    Available in iOS 5.0 and later.

  • Y Y Property

    The value located in the second position in the vector. (read-only)

    Declaration

    Swift

    var Y: CGFloat { get }

    Objective-C

    @property(readonly) CGFloat Y

    Availability

    Available in iOS 5.0 and later.

  • Z Z Property

    The value located in the third position in the vector. (read-only)

    Declaration

    Swift

    var Z: CGFloat { get }

    Objective-C

    @property(readonly) CGFloat Z

    Availability

    Available in iOS 5.0 and later.

  • W W Property

    The value located in the fourth position in the vector. (read-only)

    Declaration

    Swift

    var W: CGFloat { get }

    Objective-C

    @property(readonly) CGFloat W

    Availability

    Available in iOS 5.0 and later.

  • The string representation of the vector. (read-only)

    Declaration

    Swift

    var stringRepresentation: String { get }

    Objective-C

    @property(readonly) NSString *stringRepresentation

    Discussion

    Some example string representations of vectors :

    • @"[1.0 0.5 0.3]" — a vec3 vector whose components are X = 1.0, Y = 0.5, and Z = 0.3

    • @"[10.0 23.0] — a vec2 vector whose components are X = 10.0 and Y = 23.0

    To create a CIVector object from a string representation, use the vectorWithString: method.

    Availability

    Available in iOS 5.0 and later.

  • The values in the vector represented as an affine transform. (read-only)

    Declaration

    Swift

    var CGAffineTransformValue: CGAffineTransform { get }

    Objective-C

    @property(readonly) CGAffineTransform CGAffineTransformValue

    Discussion

    Reading this property creates a CGAffineTransform structure from the first six values in the vector.

    Availability

    Available in iOS 5.0 and later.

  • The values in the vector as a Core Graphics point structure. (read-only)

    Declaration

    Swift

    var CGPointValue: CGPoint { get }

    Objective-C

    @property(readonly) CGPoint CGPointValue

    Discussion

    Reading this property creates a CGPoint structure from the first two values (X and Y) in the vector.

    Availability

    Available in iOS 5.0 and later.

  • The values in the vector as a Core Graphics rectangle structure. (read-only)

    Declaration

    Swift

    var CGRectValue: CGRect { get }

    Objective-C

    @property(readonly) CGRect CGRectValue

    Discussion

    Reading this property creates a CGRect structure whose origin is the X and Y values in the vector and whose size is the Z and W values in the vector.

    Availability

    Available in iOS 5.0 and later.