pub struct GKNoise { /* private fields */ }GKNoise only.Expand description
GKNoise is the object used to manipulate and combine noise in continuous 3D space. It takes a GKNoiseSource as input. To extract and use a portion of the noise within the 3D space use the GKNoiseMap class.
See: GKNoiseSource
See: GKNoiseMap
See also Apple’s documentation
Implementations§
Source§impl GKNoise
impl GKNoise
Sourcepub unsafe fn gradientColors(&self) -> Retained<NSDictionary<NSNumber, NSColor>>
Available on crate feature objc2-app-kit and macOS only.
pub unsafe fn gradientColors(&self) -> Retained<NSDictionary<NSNumber, NSColor>>
objc2-app-kit and macOS only.Color gradient of this noise, represented as ‘value : color’ pairs. Utilized when this noise is rendered to a texture.
Sourcepub unsafe fn setGradientColors(
&self,
gradient_colors: &NSDictionary<NSNumber, NSColor>,
)
Available on crate feature objc2-app-kit and macOS only.
pub unsafe fn setGradientColors( &self, gradient_colors: &NSDictionary<NSNumber, NSColor>, )
objc2-app-kit and macOS only.Setter for gradientColors.
This is copied when set.
Sourcepub unsafe fn init(this: Allocated<Self>) -> Retained<Self>
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>
Initializes a constant noise of 0.0 at all positions.
Sourcepub unsafe fn noiseWithNoiseSource(
noise_source: &GKNoiseSource,
) -> Retained<Self>
Available on crate feature GKNoiseSource only.
pub unsafe fn noiseWithNoiseSource( noise_source: &GKNoiseSource, ) -> Retained<Self>
GKNoiseSource only.Initializes a noise with the specified noise source.
Parameter noiseSource: The noise source to use to initially populate the 3D noise space.
Sourcepub unsafe fn noiseWithNoiseSource_gradientColors(
noise_source: &GKNoiseSource,
gradient_colors: &NSDictionary<NSNumber, NSColor>,
) -> Retained<Self>
Available on crate feature GKNoiseSource and crate feature objc2-app-kit and macOS only.
pub unsafe fn noiseWithNoiseSource_gradientColors( noise_source: &GKNoiseSource, gradient_colors: &NSDictionary<NSNumber, NSColor>, ) -> Retained<Self>
GKNoiseSource and crate feature objc2-app-kit and macOS only.Initializes a noise with the specified noise source and parameters.
Parameter noiseSource: The noise source to use to initially populate the 3D noise space.
Parameter gradientColors: The color gradient to use for this noise in ‘value : color’ pairs.
Sourcepub unsafe fn initWithNoiseSource(
this: Allocated<Self>,
noise_source: &GKNoiseSource,
) -> Retained<Self>
Available on crate feature GKNoiseSource only.
pub unsafe fn initWithNoiseSource( this: Allocated<Self>, noise_source: &GKNoiseSource, ) -> Retained<Self>
GKNoiseSource only.Initializes a noise with the specified noise source.
Parameter noiseSource: The noise source to use to initially populate the 3D noise space.
Sourcepub unsafe fn initWithNoiseSource_gradientColors(
this: Allocated<Self>,
noise_source: &GKNoiseSource,
gradient_colors: &NSDictionary<NSNumber, NSColor>,
) -> Retained<Self>
Available on crate feature GKNoiseSource and crate feature objc2-app-kit and macOS only.
pub unsafe fn initWithNoiseSource_gradientColors( this: Allocated<Self>, noise_source: &GKNoiseSource, gradient_colors: &NSDictionary<NSNumber, NSColor>, ) -> Retained<Self>
GKNoiseSource and crate feature objc2-app-kit and macOS only.Initializes a noise with the specified noise source and parameters.
Parameter noiseSource: The noise source to use to initially populate the 3D noise space.
Parameter gradientColors: The color gradient to use for this noise in ‘value : color’ pairs.
Sourcepub unsafe fn noiseWithComponentNoises_selectionNoise(
noises: &NSArray<GKNoise>,
selection_noise: &GKNoise,
) -> Retained<Self>
pub unsafe fn noiseWithComponentNoises_selectionNoise( noises: &NSArray<GKNoise>, selection_noise: &GKNoise, ) -> Retained<Self>
Initializes a composite noise from one or more component noises. Useful for combining and layering noises together.
Parameter noises: The component noises to combine.
Parameter selectionNoise: The noise that governs which component noise is chosen for each position of the resulting noise.
The range of values is equally-subdivided for each component noise.
Sourcepub unsafe fn noiseWithComponentNoises_selectionNoise_componentBoundaries_boundaryBlendDistances(
noises: &NSArray<GKNoise>,
selection_noise: &GKNoise,
component_boundaries: &NSArray<NSNumber>,
blend_distances: &NSArray<NSNumber>,
) -> Retained<Self>
pub unsafe fn noiseWithComponentNoises_selectionNoise_componentBoundaries_boundaryBlendDistances( noises: &NSArray<GKNoise>, selection_noise: &GKNoise, component_boundaries: &NSArray<NSNumber>, blend_distances: &NSArray<NSNumber>, ) -> Retained<Self>
Initializes a composite noise from one or more component noises. Useful for combining and layering noises together.
Parameter noises: The component noises to combine.
Parameter selectionNoise: The noise that governs which component noise is chosen for each position of the resulting noise.
The range of values is equally-subdivided for each component noise.
Parameter componentBoundaries: The noise value boundaries of the selection noise to use for the component noises. Specify
one less boundary than the number of component noises. This is a parallel array to blendDistances.
Parameter blendDistances: The size of smoothing that is applied to boundaries where two component noises meet. Specify
one less blend distance than the number of component noises. This is a parallel array to componentBoundaries.
Sourcepub unsafe fn applyAbsoluteValue(&self)
pub unsafe fn applyAbsoluteValue(&self)
Takes the absoltue value of all noise positions.
Sourcepub unsafe fn clampWithLowerBound_upperBound(
&self,
lower_bound: c_double,
upper_bound: c_double,
)
pub unsafe fn clampWithLowerBound_upperBound( &self, lower_bound: c_double, upper_bound: c_double, )
Clamps all noise values to the specified bounds.
Parameter lowerBound: The noise value lower bound.
Parameter upperBound: The noise value upper bound.
Sourcepub unsafe fn raiseToPower(&self, power: c_double)
pub unsafe fn raiseToPower(&self, power: c_double)
Raises all noise values to the specified power.
Parameter power: The power to which to raise all noise values.
Sourcepub unsafe fn invert(&self)
pub unsafe fn invert(&self)
Inverts all noise values, from positive to negative and vice versa.
Sourcepub unsafe fn applyTurbulenceWithFrequency_power_roughness_seed(
&self,
frequency: c_double,
power: c_double,
roughness: c_int,
seed: i32,
)
pub unsafe fn applyTurbulenceWithFrequency_power_roughness_seed( &self, frequency: c_double, power: c_double, roughness: c_int, seed: i32, )
Applies a turbulent displacement to all noise values.
Sourcepub unsafe fn remapValuesToCurveWithControlPoints(
&self,
control_points: &NSDictionary<NSNumber, NSNumber>,
)
pub unsafe fn remapValuesToCurveWithControlPoints( &self, control_points: &NSDictionary<NSNumber, NSNumber>, )
Remaps all noise values to a smooth curve that passes through the specified control points.
Parameter controlPoints: Pairs of ‘input : output’ values to use as control points for the smooth remapping curve.
Duplicate input values are not permitted.
Sourcepub unsafe fn remapValuesToTerracesWithPeaks_terracesInverted(
&self,
peak_input_values: &NSArray<NSNumber>,
inverted: bool,
)
pub unsafe fn remapValuesToTerracesWithPeaks_terracesInverted( &self, peak_input_values: &NSArray<NSNumber>, inverted: bool, )
Remaps all noise values to one or more terraces with peaks. Useful for creating valleys and trenches.
Parameter peakInputValues: Inputs positions of terrace peaks.
Parameter inverted: Governs the curve direction from peak to peak.
Sourcepub unsafe fn addWithNoise(&self, noise: &GKNoise)
pub unsafe fn addWithNoise(&self, noise: &GKNoise)
Adds all noise values by the noise values at the same position in specified noise.
Parameter noise: The noise from which to add values to this noise.
Sourcepub unsafe fn multiplyWithNoise(&self, noise: &GKNoise)
pub unsafe fn multiplyWithNoise(&self, noise: &GKNoise)
Multiplies all noise values by the noise values at the same position in specified noise.
Parameter noise: The noise from which to multiply values to this noise.
Sourcepub unsafe fn minimumWithNoise(&self, noise: &GKNoise)
pub unsafe fn minimumWithNoise(&self, noise: &GKNoise)
Takes the minimum value between this noise and the specified noise at each position.
Parameter noise: The noise to compare against this noise at each position in determining which to take the minimum value from.
Sourcepub unsafe fn maximumWithNoise(&self, noise: &GKNoise)
pub unsafe fn maximumWithNoise(&self, noise: &GKNoise)
Takes the maximum value between this noise and the specified noise at each position.
Parameter noise: The noise to compare against this noise at each position in determining which to take the maximum value from.
Sourcepub unsafe fn raiseToPowerWithNoise(&self, noise: &GKNoise)
pub unsafe fn raiseToPowerWithNoise(&self, noise: &GKNoise)
Raises all noise values to the power of the value at the same position of the specified noise.
Parameter noise: The noise from which to raise this noise’s values by.
Sourcepub unsafe fn displaceXWithNoise_yWithNoise_zWithNoise(
&self,
x_displacement_noise: &GKNoise,
y_displacement_noise: &GKNoise,
z_displacement_noise: &GKNoise,
)
pub unsafe fn displaceXWithNoise_yWithNoise_zWithNoise( &self, x_displacement_noise: &GKNoise, y_displacement_noise: &GKNoise, z_displacement_noise: &GKNoise, )
Displaces all noise values by the values at the same positions of the specified noises.
Parameter xDisplacementNoise: The noise from which to displace along the x-axis this noise’s values at the same positions.
Parameter yDisplacementNoise: The noise from which to displace along the y-axis this noise’s values at the same positions.
Parameter zDisplacementNoise: The noise from which to displace along the z-axis this noise’s values at the same positions.
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 GKNoise
impl ClassType for GKNoise
Source§const NAME: &'static str = "GKNoise"
const NAME: &'static str = "GKNoise"
Source§type ThreadKind = <<GKNoise as ClassType>::Super as ClassType>::ThreadKind
type ThreadKind = <<GKNoise as ClassType>::Super as ClassType>::ThreadKind
Source§impl NSObjectProtocol for GKNoise
impl NSObjectProtocol for GKNoise
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