Type Alias freya_engine::prelude::svg::Dom
pub type Dom = RCHandle<SkSVGDOM>;
Aliased Type§
struct Dom(/* private fields */);
Implementations
§impl RCHandle<SkSVGDOM>
impl RCHandle<SkSVGDOM>
This type represents an SVG as a node-based data structure.
To convert an SVG to a Dom
, a [NativeResourceProvider
] is required.
§Creating a Resource Provider
To create a resource provider, a crate::FontMgr
is required at a minimum.
- If you don’t need font support, pass [
crate::FontMgr::new_empty()
] as the resource provider. - To use the installed fonts on your system, pass [
crate::FontMgr::default()
] as the resource provider.
When you pass a crate::FontMgr
as the resource provider, a
crate::resources::LocalResourceProvider
is created behind the scenes. This provider, in
addition to supporting typefaces, also adds support for data:
URLs.
§Supporting External Resources
To support http://
or https://
external resources, enable the ureq
feature and create a
[crate::resources::UReqResourceProvider
].
§Custom Resource Providers
If you need more customization, you can implement the trait [crate::resources::ResourceProvider
].
pub fn read<R>(
reader: R,
resource_provider: impl Into<RCHandle<RustResourceProvider>>,
) -> Result<RCHandle<SkSVGDOM>, LoadError>where
R: Read,
pub fn from_str( svg: impl AsRef<str>, resource_provider: impl Into<RCHandle<RustResourceProvider>>, ) -> Result<RCHandle<SkSVGDOM>, LoadError>
pub fn from_bytes( svg: &[u8], resource_provider: impl Into<RCHandle<RustResourceProvider>>, ) -> Result<RCHandle<SkSVGDOM>, LoadError>
pub fn root(&self) -> RCHandle<SkSVGSVG>
pub fn render(&self, canvas: &Canvas)
pub fn set_container_size(&mut self, size: impl Into<Size>)
§impl<T> RCHandle<T>where
T: NativeRefCounted + NodeSubtype,
impl<T> RCHandle<T>where
T: NativeRefCounted + NodeSubtype,
pub fn as_base(&self) -> &RCHandle<<T as NodeSubtype>::Base>
pub fn as_base_mut(&mut self) -> &mut RCHandle<<T as NodeSubtype>::Base>
Trait Implementations
§impl<H> ConditionallySend for RCHandle<H>where
H: NativeRefCountedBase,
impl<H> ConditionallySend for RCHandle<H>where
H: NativeRefCountedBase,
RCHandle<H>
is conditionally Send and can be sent to
another thread when its reference count is 1.
§impl<N> Debug for RCHandle<N>where
N: NativeRefCounted,
RCHandle<N>: DebugAttributes,
impl<N> Debug for RCHandle<N>where
N: NativeRefCounted,
RCHandle<N>: DebugAttributes,
§impl<T> Deref for RCHandle<T>where
T: NativeRefCounted + NodeSubtype,
impl<T> Deref for RCHandle<T>where
T: NativeRefCounted + NodeSubtype,
§impl<T> DerefMut for RCHandle<T>where
T: NativeRefCounted + NodeSubtype,
impl<T> DerefMut for RCHandle<T>where
T: NativeRefCounted + NodeSubtype,
This implementation of DerefMut
causes subsequent UB when the containing
[RCHandle
] gets overwritten by a base type that does not match the actual
underlying type.
§impl<N> Flattenable for RCHandle<N>where
N: NativeFlattenable + NativeRefCountedBase,
impl<N> Flattenable for RCHandle<N>where
N: NativeFlattenable + NativeRefCountedBase,
§impl<N> From<&RCHandle<N>> for RCHandle<N>where
N: NativeRefCounted,
impl<N> From<&RCHandle<N>> for RCHandle<N>where
N: NativeRefCounted,
A reference counted handle is cheap to clone, so we do support a conversion from a reference to a ref counter to an owned handle.