pub struct CIVector { /* private fields */ }CIVector only.Expand description
The Core Image class that defines a vector object.
A CIVector can store one or more CGFloat in one object. They can store a group of float values
for a variety of different uses such as coordinate points, direction vectors, geometric rectangles,
transform matrices, convolution weights, or just a list a parameter values.
You use CIVector objects in conjunction with other Core Image classes, such as CIFilter-class
and CIKernel. Many of the built-in Core Image filters have one or more CIVector inputs that
you can set to affect the filter’s behavior.
See also Apple’s documentation
Implementations§
Source§impl CIVector
impl CIVector
Sourcepub unsafe fn vectorWithValues_count(
values: NonNull<CGFloat>,
count: usize,
) -> Retained<Self>
Available on crate feature objc2-core-foundation only.
pub unsafe fn vectorWithValues_count( values: NonNull<CGFloat>, count: usize, ) -> Retained<Self>
objc2-core-foundation only.Create a Core Image vector object that is initialized with the specified values.
- Parameters:
- values: The pointer
CGFloatvalues to initialize the vector with. - count: The number of
CGFloatsspecified by thevaluesparameter. - Returns:
An autoreleased
CIVectorobject of lengthcount.
§Safety
values must be a valid pointer.
Sourcepub unsafe fn vectorWithX(x: CGFloat) -> Retained<Self>
Available on crate feature objc2-core-foundation only.
pub unsafe fn vectorWithX(x: CGFloat) -> Retained<Self>
objc2-core-foundation only.Create a Core Image vector object that is initialized with one value.
- Parameters:
- x: The value for the first position in the vector.
- Returns:
An autoreleased
CIVectorobject of length 1.
Sourcepub unsafe fn vectorWithX_Y(x: CGFloat, y: CGFloat) -> Retained<Self>
Available on crate feature objc2-core-foundation only.
pub unsafe fn vectorWithX_Y(x: CGFloat, y: CGFloat) -> Retained<Self>
objc2-core-foundation only.Create a Core Image vector object that is initialized with two values.
- Parameters:
- x: The value for the first position in the vector.
- y: The value for the second position in the vector.
- Returns:
An autoreleased
CIVectorobject of length 2.
Sourcepub unsafe fn vectorWithX_Y_Z(
x: CGFloat,
y: CGFloat,
z: CGFloat,
) -> Retained<Self>
Available on crate feature objc2-core-foundation only.
pub unsafe fn vectorWithX_Y_Z( x: CGFloat, y: CGFloat, z: CGFloat, ) -> Retained<Self>
objc2-core-foundation only.Create a Core Image vector object that is initialized with three values.
- 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.
- Returns:
An autoreleased
CIVectorobject of length 3.
Sourcepub unsafe fn vectorWithX_Y_Z_W(
x: CGFloat,
y: CGFloat,
z: CGFloat,
w: CGFloat,
) -> Retained<Self>
Available on crate feature objc2-core-foundation only.
pub unsafe fn vectorWithX_Y_Z_W( x: CGFloat, y: CGFloat, z: CGFloat, w: CGFloat, ) -> Retained<Self>
objc2-core-foundation only.Create a Core Image vector object that is initialized with four values.
- 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 forth position in the vector.
- Returns:
An autoreleased
CIVectorobject of length 4.
Sourcepub unsafe fn vectorWithCGPoint(p: CGPoint) -> Retained<Self>
Available on crate feature objc2-core-foundation only.
pub unsafe fn vectorWithCGPoint(p: CGPoint) -> Retained<Self>
objc2-core-foundation only.Create a Core Image vector object that is initialized with two values provided by a CGPoint structure.
The CGRect structure’s y and y values
are stored in the vector’s two values.
- Parameters:
- p: The
CGPointstructure. - Returns:
An autoreleased
CIVectorobject of length 2.
Sourcepub unsafe fn vectorWithCGRect(r: CGRect) -> Retained<Self>
Available on crate feature objc2-core-foundation only.
pub unsafe fn vectorWithCGRect(r: CGRect) -> Retained<Self>
objc2-core-foundation only.Create a Core Image vector object that is initialized with four values provided by a CGRect structure.
The CGRect structure’s x, y, height and width values
are stored in the vector’s four values.
- Parameters:
- r: The
CGRectstructure. - Returns:
An autoreleased
CIVectorobject of length 4.
Sourcepub unsafe fn vectorWithCGAffineTransform(
t: CGAffineTransform,
) -> Retained<Self>
Available on crate feature objc2-core-foundation only.
pub unsafe fn vectorWithCGAffineTransform( t: CGAffineTransform, ) -> Retained<Self>
objc2-core-foundation only.Create a Core Image vector object that is initialized with six values provided by a CGAffineTransform structure.
The CGAffineTransform structure’s a, b, c, d, tx and ty values
are stored in the vector’s six values.
- Parameters:
- t: The
CGAffineTransformstructure. - Returns:
An autoreleased
CIVectorobject of length 6.
Sourcepub unsafe fn vectorWithString(representation: &NSString) -> Retained<Self>
pub unsafe fn vectorWithString(representation: &NSString) -> Retained<Self>
Create a Core Image vector object with values provided in a string representation.
- Parameters:
- representation: A string that is in one of the formats returned by the
stringRepresentationmethod. - Returns:
An autoreleased
CIVectorobject.
Sourcepub unsafe fn initWithValues_count(
this: Allocated<Self>,
values: NonNull<CGFloat>,
count: usize,
) -> Retained<Self>
Available on crate feature objc2-core-foundation only.
pub unsafe fn initWithValues_count( this: Allocated<Self>, values: NonNull<CGFloat>, count: usize, ) -> Retained<Self>
objc2-core-foundation only.Initialize a Core Image vector object with the specified the values.
- Parameters:
- values: A pointer
CGFloatvalues for vector. - count: The number of
CGFloatsspecified by thevaluesparameter. - Returns:
An initialized
CIVectorobject of lengthcount.
§Safety
values must be a valid pointer.
Sourcepub unsafe fn initWithX(this: Allocated<Self>, x: CGFloat) -> Retained<Self>
Available on crate feature objc2-core-foundation only.
pub unsafe fn initWithX(this: Allocated<Self>, x: CGFloat) -> Retained<Self>
objc2-core-foundation only.Initialize a Core Image vector object with one value.
- Parameters:
- x: The value for the first position in the vector.
- Returns:
An initialized
CIVectorobject of length 1.
Sourcepub unsafe fn initWithX_Y(
this: Allocated<Self>,
x: CGFloat,
y: CGFloat,
) -> Retained<Self>
Available on crate feature objc2-core-foundation only.
pub unsafe fn initWithX_Y( this: Allocated<Self>, x: CGFloat, y: CGFloat, ) -> Retained<Self>
objc2-core-foundation only.Initialize a Core Image vector object with two values.
- Parameters:
- x: The value for the first position in the vector.
- y: The value for the second position in the vector.
- Returns:
An initialized
CIVectorobject of length 2.
Sourcepub unsafe fn initWithX_Y_Z(
this: Allocated<Self>,
x: CGFloat,
y: CGFloat,
z: CGFloat,
) -> Retained<Self>
Available on crate feature objc2-core-foundation only.
pub unsafe fn initWithX_Y_Z( this: Allocated<Self>, x: CGFloat, y: CGFloat, z: CGFloat, ) -> Retained<Self>
objc2-core-foundation only.Initialize a Core Image vector object with three values.
- 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.
- Returns:
An initialized
CIVectorobject of length 3.
Sourcepub unsafe fn initWithX_Y_Z_W(
this: Allocated<Self>,
x: CGFloat,
y: CGFloat,
z: CGFloat,
w: CGFloat,
) -> Retained<Self>
Available on crate feature objc2-core-foundation only.
pub unsafe fn initWithX_Y_Z_W( this: Allocated<Self>, x: CGFloat, y: CGFloat, z: CGFloat, w: CGFloat, ) -> Retained<Self>
objc2-core-foundation only.Initialize a Core Image vector object with four values.
- 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 forth position in the vector.
- Returns:
An initialized
CIVectorobject of length 4.
Sourcepub unsafe fn initWithCGPoint(
this: Allocated<Self>,
p: CGPoint,
) -> Retained<Self>
Available on crate feature objc2-core-foundation only.
pub unsafe fn initWithCGPoint( this: Allocated<Self>, p: CGPoint, ) -> Retained<Self>
objc2-core-foundation only.Initialize a Core Image vector object with two values provided by a CGPoint structure.
The CGRect structure’s y and y values
are stored in the vector’s two values.
- Parameters:
- p: The
CGPointstructure. - Returns:
An initialized
CIVectorobject of length 2.
Sourcepub unsafe fn initWithCGRect(this: Allocated<Self>, r: CGRect) -> Retained<Self>
Available on crate feature objc2-core-foundation only.
pub unsafe fn initWithCGRect(this: Allocated<Self>, r: CGRect) -> Retained<Self>
objc2-core-foundation only.Initialize a Core Image vector object with four values provided by a CGRect structure.
The CGRect structure’s x, y, height and width values
are stored in the vector’s four values.
- Parameters:
- r: The
CGRectstructure. - Returns:
An initialized
CIVectorobject of length 4.
Sourcepub unsafe fn initWithCGAffineTransform(
this: Allocated<Self>,
t: CGAffineTransform,
) -> Retained<Self>
Available on crate feature objc2-core-foundation only.
pub unsafe fn initWithCGAffineTransform( this: Allocated<Self>, t: CGAffineTransform, ) -> Retained<Self>
objc2-core-foundation only.Initialize a Core Image vector object with six values provided by a CGAffineTransform structure.
The CGAffineTransform structure’s a, b, c, c, tx and ty values
are stored in the vector’s six values.
- Parameters:
- t: The
CGAffineTransformstructure. - Returns:
An initialized
CIVectorobject of length 6.
Sourcepub unsafe fn initWithString(
this: Allocated<Self>,
representation: &NSString,
) -> Retained<Self>
pub unsafe fn initWithString( this: Allocated<Self>, representation: &NSString, ) -> Retained<Self>
Initialize a Core Image vector object with values provided in a string representation.
- Parameters:
- representation: A string that is in one of the formats returned by the
stringRepresentationmethod. - Returns:
An initialized
CIVectorobject.
Sourcepub unsafe fn valueAtIndex(&self, index: usize) -> CGFloat
Available on crate feature objc2-core-foundation only.
pub unsafe fn valueAtIndex(&self, index: usize) -> CGFloat
objc2-core-foundation only.Returns a value from a specific position in the vector.
The numbering of elements in a vector begins with zero.
- Parameters:
- index: The position in the vector of the value that you want to retrieve.
- Returns:
The value retrieved from the vector or
0if the position is undefined.
Sourcepub unsafe fn X(&self) -> CGFloat
Available on crate feature objc2-core-foundation only.
pub unsafe fn X(&self) -> CGFloat
objc2-core-foundation only.The value located in the first position in the vector.
Sourcepub unsafe fn Y(&self) -> CGFloat
Available on crate feature objc2-core-foundation only.
pub unsafe fn Y(&self) -> CGFloat
objc2-core-foundation only.The value located in the second position in the vector.
Sourcepub unsafe fn Z(&self) -> CGFloat
Available on crate feature objc2-core-foundation only.
pub unsafe fn Z(&self) -> CGFloat
objc2-core-foundation only.The value located in the third position in the vector.
Sourcepub unsafe fn W(&self) -> CGFloat
Available on crate feature objc2-core-foundation only.
pub unsafe fn W(&self) -> CGFloat
objc2-core-foundation only.The value located in the forth position in the vector.
Sourcepub unsafe fn CGPointValue(&self) -> CGPoint
Available on crate feature objc2-core-foundation only.
pub unsafe fn CGPointValue(&self) -> CGPoint
objc2-core-foundation only.Returns the values in the vector as a CGPoint structure.
- Returns:
Reading this property returns a
CGPointstructure from theXandYvalues from the vector.
Sourcepub unsafe fn CGRectValue(&self) -> CGRect
Available on crate feature objc2-core-foundation only.
pub unsafe fn CGRectValue(&self) -> CGRect
objc2-core-foundation only.Returns the values in the vector as a CGRect structure.
- Returns:
Reading this property creates a
CGRectstructure whose origin is theX,Y,ZandWvalues from the vector.
Sourcepub unsafe fn CGAffineTransformValue(&self) -> CGAffineTransform
Available on crate feature objc2-core-foundation only.
pub unsafe fn CGAffineTransformValue(&self) -> CGAffineTransform
objc2-core-foundation only.Returns the values in the vector as a CGAffineTransformValue structure.
- Returns:
Reading this property creates a
CGAffineTransformValuestructure from the first six values in the vector.
Sourcepub unsafe fn stringRepresentation(&self) -> Retained<NSString>
pub unsafe fn stringRepresentation(&self) -> Retained<NSString>
Returns a formatted string with all the values of a CIVector.
Some example string representations of vectors:
CIVector | stringRepresentation |
|---|---|
[CIVector vectorWithX:1.0 Y:0.5 Z:0.3] | "[1.0 0.5 0.3]" |
[CIVector vectorWithX:10.0 Y:23.0] | "[10.0 23.0]" |
To create a CIVector object from a string representation, use the vectorWithString: method.
Methods from Deref<Target = NSObject>§
Sourcepub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
pub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
Handle messages the object doesn’t recognize.
See Apple’s documentation for details.
Methods from Deref<Target = AnyObject>§
Sourcepub fn class(&self) -> &'static AnyClass
pub fn class(&self) -> &'static AnyClass
Dynamically find the class of this object.
§Panics
May panic if the object is invalid (which may be the case for objects
returned from unavailable init/new methods).
§Example
Check that an instance of NSObject has the precise class NSObject.
use objc2::ClassType;
use objc2::runtime::NSObject;
let obj = NSObject::new();
assert_eq!(obj.class(), NSObject::class());Sourcepub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
👎Deprecated: this is difficult to use correctly, use Ivar::load instead.
pub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
Ivar::load instead.Use Ivar::load instead.
§Safety
The object must have an instance variable with the given name, and it
must be of type T.
See Ivar::load_ptr for details surrounding this.
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
pub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
Attempt to downcast the object to a class of type T.
This is the reference-variant. Use Retained::downcast if you want
to convert a retained object to another type.
§Mutable classes
Some classes have immutable and mutable variants, such as NSString
and NSMutableString.
When some Objective-C API signature says it gives you an immutable class, it generally expects you to not mutate that, even though it may technically be mutable “under the hood”.
So using this method to convert a NSString to a NSMutableString,
while not unsound, is generally frowned upon unless you created the
string yourself, or the API explicitly documents the string to be
mutable.
See Apple’s documentation on mutability and on
isKindOfClass: for more details.
§Generic classes
Objective-C generics are called “lightweight generics”, and that’s because they aren’t exposed in the runtime. This makes it impossible to safely downcast to generic collections, so this is disallowed by this method.
You can, however, safely downcast to generic collections where all the
type-parameters are AnyObject.
§Panics
This works internally by calling isKindOfClass:. That means that the
object must have the instance method of that name, and an exception
will be thrown (if CoreFoundation is linked) or the process will abort
if that is not the case. In the vast majority of cases, you don’t need
to worry about this, since both root objects NSObject and
NSProxy implement this method.
§Examples
Cast an NSString back and forth from NSObject.
use objc2::rc::Retained;
use objc2_foundation::{NSObject, NSString};
let obj: Retained<NSObject> = NSString::new().into_super();
let string = obj.downcast_ref::<NSString>().unwrap();
// Or with `downcast`, if we do not need the object afterwards
let string = obj.downcast::<NSString>().unwrap();Try (and fail) to cast an NSObject to an NSString.
use objc2_foundation::{NSObject, NSString};
let obj = NSObject::new();
assert!(obj.downcast_ref::<NSString>().is_none());Try to cast to an array of strings.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
// This is invalid and doesn't type check.
let arr = arr.downcast_ref::<NSArray<NSString>>();This fails to compile, since it would require enumerating over the array to ensure that each element is of the desired type, which is a performance pitfall.
Downcast when processing each element instead.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
for elem in arr {
if let Some(data) = elem.downcast_ref::<NSString>() {
// handle `data`
}
}Trait Implementations§
Source§impl ClassType for CIVector
impl ClassType for CIVector
Source§const NAME: &'static str = "CIVector"
const NAME: &'static str = "CIVector"
Source§type ThreadKind = <<CIVector as ClassType>::Super as ClassType>::ThreadKind
type ThreadKind = <<CIVector as ClassType>::Super as ClassType>::ThreadKind
Source§impl CopyingHelper for CIVector
impl CopyingHelper for CIVector
Source§impl NSCopying for CIVector
impl NSCopying for CIVector
Source§impl NSObjectProtocol for CIVector
impl NSObjectProtocol for CIVector
Source§fn isEqual(&self, other: Option<&AnyObject>) -> bool
fn isEqual(&self, other: Option<&AnyObject>) -> bool
Source§fn hash(&self) -> usize
fn hash(&self) -> usize
Source§fn isKindOfClass(&self, cls: &AnyClass) -> bool
fn isKindOfClass(&self, cls: &AnyClass) -> bool
Source§fn is_kind_of<T>(&self) -> bool
fn is_kind_of<T>(&self) -> bool
isKindOfClass directly, or cast your objects with AnyObject::downcast_ref