Add from_svg and to_svg functions to Path
-use crate::prelude::{IfBoolSome, NativeAccess};
+use crate::prelude::{Handle, IfBoolSome, NativeAccess};
use crate::{interop, Path};
-use skia_bindings::{SkParsePath_FromSVGString, SkParsePath_ToSVGString};
+use skia_bindings::{SkParsePath_FromSVGString, SkParsePath_ToSVGString, SkPath};
use std::ffi::CString;
pub fn from_svg(svg: impl AsRef<str>) -> Option<Path> {
@@ -15,3 +15,13 @@ pub fn to_svg(path: &Path) -> String {
svg.as_str().into()
}
+
+impl Handle<SkPath> {
+ pub fn from_svg(svg: impl AsRef<str>) -> Option<Path> {
+ from_svg(svg)
+ }
+
+ pub fn to_svg(&self) -> String {
+ to_svg(self)
+ }
+}
