pub struct SvgFrame(/* private fields */);Expand description
A portable SVG presentation with Kit-native transform conversion.
Implementations§
Source§impl SvgFrame
impl SvgFrame
Sourcepub fn transformation(self) -> Transformation
pub fn transformation(self) -> Transformation
Converts to Kit’s center-origin SVG transform: signed scale, then rotation. Only the drawing angle is reduced modulo one turn, preserving the engine’s unwrapped presentation and velocity. This replaces any existing SVG transform.
Sourcepub fn transformation_about(
self,
bounds: Size<Pixels>,
pivot: Point<Pixels>,
) -> Transformation
pub fn transformation_about( self, bounds: Size<Pixels>, pivot: Point<Pixels>, ) -> Transformation
Converts with a custom pivot expressed as logical pixels from the SVG’s top-left. Supply its untransformed bounds size. Translation compensates for Kit’s fixed center origin. Native layout/hitbox remain unchanged.
Sourcepub fn apply(self, element: Svg) -> Svg
pub fn apply(self, element: Svg) -> Svg
Applies GPU scale/rotation to one Kit SVG drawing around its bounds center. Native layout and hitbox stay unchanged, and clipping follows Kit’s existing axis-aligned masks. This does not transform surrounding divs, text, or children. Use a fixed, sufficiently padded parent as the interactive hit target.
use gpui_kit::{svg, prelude::*, px};
use gpui_motion_kit::{SvgMotionState, core::{SvgMotion, SvgTarget}};
use std::time::Duration;
let mut state = SvgMotionState::default();
let frame = state.sample(SvgMotion::new(SvgTarget::default().scale(1.2).rotate_degrees(30.0)), Duration::ZERO, false);
let element = frame.apply(svg().path("icons/arrow.svg").size(px(24.0)));Methods from Deref<Target = SvgFrame>§
Sourcepub fn target(self) -> SvgTarget
pub fn target(self) -> SvgTarget
Presented signed scales, unwrapped rotation and drawing translation.
Sourcepub fn translation_velocity(self) -> [f64; 2]
pub fn translation_velocity(self) -> [f64; 2]
Drawing translation velocity, logical pixels/second.
Sourcepub fn is_animating(self) -> bool
pub fn is_animating(self) -> bool
Whether another frame is needed. False after settling or a reduced-motion snap.
Sourcepub fn just_completed(self) -> bool
pub fn just_completed(self) -> bool
Completion edge when the final active channel finishes; consumed by this sample.
Trait Implementations§
impl Copy for SvgFrame
Auto Trait Implementations§
impl Freeze for SvgFrame
impl RefUnwindSafe for SvgFrame
impl Send for SvgFrame
impl Sync for SvgFrame
impl Unpin for SvgFrame
impl UnsafeUnpin for SvgFrame
impl UnwindSafe for SvgFrame
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more