Skip to main content

GradientTransform

Trait GradientTransform 

Source
pub trait GradientTransform: Any + Debug {
    // Required methods
    fn transform(
        &self,
        bounds: Rect,
        text_direction: Option<TextDirection>,
    ) -> Option<Matrix>;
    fn as_any(&self) -> &(dyn Any + 'static);

    // Provided method
    fn eq_transform(&self, other: &(dyn GradientTransform + 'static)) -> bool { ... }
}
Expand description

Base class for transforming gradient shaders without applying the same transform to the entire canvas.

For example, a SweepGradient normally starts its gradation at 3 o’clock and draws clockwise. To have the sweep appear to start at 6 o’clock, supply a GradientRotation of pi/4 radians (i.e. 45 degrees).

Required Methods§

Source

fn transform( &self, bounds: Rect, text_direction: Option<TextDirection>, ) -> Option<Matrix>

When a Gradient creates its Shader, it will call this method to determine what transform to apply to the shader for the given Rect and TextDirection.

Implementers may return None from this method, which achieves the same final effect as returning Matrix4::IDENTITY.

Source

fn as_any(&self) -> &(dyn Any + 'static)

Downcast support for is / as in Dart.

Provided Methods§

Source

fn eq_transform(&self, other: &(dyn GradientTransform + 'static)) -> bool

Field equality. Dart’s default == is identity; subclasses that override == implement this.

Trait Implementations§

Source§

impl PartialEq for dyn GradientTransform

Source§

fn eq(&self, other: &(dyn GradientTransform + 'static)) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§