Skip to main content

Svg

Struct Svg 

Source
pub struct Svg { /* private fields */ }
Expand description

a parsed SVG document (immutable; render it as often as needed)

Implementations§

Source§

impl Svg

Source

pub fn parse(data: &[u8]) -> Result<Svg, i32>

parse an SVG document (UTF-8 XML; gzip data (.svgz) is inflated first): Err(ERR_HDR) when it is no SVG, ERR_LIMIT beyond the size limits

Source

pub fn size(&self) -> (f64, f64)

the intrinsic size in px (CSS px = DIP): width / height of the root, else its viewBox, else 300 x 150

Source

pub fn view_box(&self) -> Option<[f64; 4]>

the root’s viewBox (x, y, w, h), if it has one

Source

pub fn title(&self) -> &str

the text of the root’s (blanks collapsed; empty without one)</p> </div></details><details class="toggle method-toggle" open><summary><section id="method.truncated" class="method"><a class="src rightside" href="https://docs.rs/jflib-img-svg/0.1.0/aarch64-linux-android/src/img_svg/doc.rs.html#381">Source</a><h4 class="code-header">pub fn <a href="#method.truncated" class="fn">truncated</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>the file ended early or a limit dropped elements (what was read is drawn)</p> </div></details><details class="toggle method-toggle" open><summary><section id="method.element_count" class="method"><a class="src rightside" href="https://docs.rs/jflib-img-svg/0.1.0/aarch64-linux-android/src/img_svg/doc.rs.html#386">Source</a><h4 class="code-header">pub fn <a href="#method.element_count" class="fn">element_count</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></h4></section></summary><div class="docblock"><p>the number of elements</p> </div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Svg-1" class="impl"><a class="src rightside" href="https://docs.rs/jflib-img-svg/0.1.0/aarch64-linux-android/src/img_svg/render.rs.html#1385">Source</a><a href="#impl-Svg-1" class="anchor">§</a><h3 class="code-header">impl <a class="struct" href="struct.Svg.html" title="struct ui::Svg">Svg</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.render" class="method"><a class="src rightside" href="https://docs.rs/jflib-img-svg/0.1.0/aarch64-linux-android/src/img_svg/render.rs.html#1391">Source</a><h4 class="code-header">pub fn <a href="#method.render" class="fn">render</a>( &self, sf: &mut <a class="struct" href="https://docs.rs/jflib-gfx/0.1.0/aarch64-linux-android/gfx/struct.Surface.html" title="struct gfx::Surface">Surface</a>, m: &<a class="struct" href="https://docs.rs/jflib-gfx/0.1.0/aarch64-linux-android/gfx/xform/struct.Matrix.html" title="struct gfx::xform::Matrix">Matrix</a>, clip: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><[<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.array.html">4</a>]>, opts: &mut <a class="struct" href="https://docs.rs/jflib-img-svg/0.1.0/aarch64-linux-android/img_svg/render/struct.Opts.html" title="struct img_svg::render::Opts">Opts</a><'_>, )</h4></section></summary><div class="docblock"><p>draw the document: its viewport (the intrinsic size, viewBox mapped by preserveAspectRatio) through m (intrinsic px -> surface px); clip: the surface rectangle x0, y0, x1, y1 (exclusive) that may change (None: all of it). Content outside the viewport is clipped (to its box under m). The surface: FMT_PARGB, or the window’s FMT_XRGB (blended the same way)</p> </div></details><details class="toggle method-toggle" open><summary><section id="method.render_rect" class="method"><a class="src rightside" href="https://docs.rs/jflib-img-svg/0.1.0/aarch64-linux-android/src/img_svg/render.rs.html#1398">Source</a><h4 class="code-header">pub fn <a href="#method.render_rect" class="fn">render_rect</a>( &self, sf: &mut <a class="struct" href="https://docs.rs/jflib-gfx/0.1.0/aarch64-linux-android/gfx/struct.Surface.html" title="struct gfx::Surface">Surface</a>, x: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a>, y: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a>, w: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a>, h: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a>, clip: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><[<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.array.html">4</a>]>, opts: &mut <a class="struct" href="https://docs.rs/jflib-img-svg/0.1.0/aarch64-linux-android/img_svg/render/struct.Opts.html" title="struct img_svg::render::Opts">Opts</a><'_>, )</h4></section></summary><div class="docblock"><p>draw the document into the rectangle x, y, w, h of the surface as its viewport (the viewBox mapped into it by preserveAspectRatio: sharp at any size)</p> </div></details><details class="toggle method-toggle" open><summary><section id="method.rasterize" class="method"><a class="src rightside" href="https://docs.rs/jflib-img-svg/0.1.0/aarch64-linux-android/src/img_svg/render.rs.html#1407">Source</a><h4 class="code-header">pub fn <a href="#method.rasterize" class="fn">rasterize</a>( &self, w: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>, h: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>, opts: &mut <a class="struct" href="https://docs.rs/jflib-img-svg/0.1.0/aarch64-linux-android/img_svg/render/struct.Opts.html" title="struct img_svg::render::Opts">Opts</a><'_>, ) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="https://docs.rs/jflib-gfx/0.1.0/aarch64-linux-android/gfx/struct.Surface.html" title="struct gfx::Surface">Surface</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>></h4></section></summary><div class="docblock"><p>a new FMT_PARGB surface w x h with the document drawn into it (render_rect); Err(ERR_DIMS) for sides outside 1 .. 65535, Err(ERR_LIMIT) beyond IMG_MAXPX_DEF pixels</p> </div></details></div></details></div><h2 id="synthetic-implementations" class="section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor">§</a></h2><div id="synthetic-implementations-list"><section id="impl-Freeze-for-Svg" class="impl"><a href="#impl-Freeze-for-Svg" class="anchor">§</a><h3 class="code-header">impl !<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Freeze.html" title="trait core::marker::Freeze">Freeze</a> for <a class="struct" href="struct.Svg.html" title="struct ui::Svg">Svg</a></h3></section><section id="impl-RefUnwindSafe-for-Svg" class="impl"><a href="#impl-RefUnwindSafe-for-Svg" class="anchor">§</a><h3 class="code-header">impl !<a class="trait" href="https://doc.rust-lang.org/nightly/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="struct.Svg.html" title="struct ui::Svg">Svg</a></h3></section><section id="impl-Forget-for-Svg" class="impl"><a href="#impl-Forget-for-Svg" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Forget.html" title="trait core::marker::Forget">Forget</a> for <a class="struct" href="struct.Svg.html" title="struct ui::Svg">Svg</a></h3></section><section id="impl-Send-for-Svg" class="impl"><a href="#impl-Send-for-Svg" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="struct.Svg.html" title="struct ui::Svg">Svg</a></h3></section><section id="impl-Sync-for-Svg" class="impl"><a href="#impl-Sync-for-Svg" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="struct.Svg.html" title="struct ui::Svg">Svg</a></h3></section><section id="impl-Unpin-for-Svg" class="impl"><a href="#impl-Unpin-for-Svg" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="struct.Svg.html" title="struct ui::Svg">Svg</a></h3></section><section id="impl-UnsafeUnpin-for-Svg" class="impl"><a href="#impl-UnsafeUnpin-for-Svg" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.UnsafeUnpin.html" title="trait core::marker::UnsafeUnpin">UnsafeUnpin</a> for <a class="struct" href="struct.Svg.html" title="struct ui::Svg">Svg</a></h3></section><section id="impl-UnwindSafe-for-Svg" class="impl"><a href="#impl-UnwindSafe-for-Svg" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <a class="struct" href="struct.Svg.html" title="struct ui::Svg">Svg</a></h3></section></div><h2 id="blanket-implementations" class="section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor">§</a></h2><div id="blanket-implementations-list"><details class="toggle implementors-toggle"><summary><section id="impl-Any-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#142">Source</a><a href="#impl-Any-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T<div class="where">where T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#143">Source</a><a href="#method.type_id" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fn">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></h4></section></summary><div class='docblock'>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#212">Source</a><a href="#impl-Borrow%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T<div class="where">where T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#214">Source</a><a href="#method.borrow" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fn">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&T</a></h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#221">Source</a><a href="#impl-BorrowMut%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T<div class="where">where T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#222">Source</a><a href="#method.borrow_mut" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fn">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut T</a></h4></section></summary><div class='docblock'>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></div></details></div></details><section id="impl-ErasedDestructor-for-T" class="impl"><a class="src rightside" href="https://docs.rs/yoke/0.8.3/aarch64-linux-android/src/yoke/erased.rs.html#22">Source</a><a href="#impl-ErasedDestructor-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://docs.rs/yoke/0.8.3/aarch64-linux-android/yoke/erased/trait.ErasedDestructor.html" title="trait yoke::erased::ErasedDestructor">ErasedDestructor</a> for T<div class="where">where T: 'static,</div></h3></section><details class="toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#787">Source</a><a href="#impl-From%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#790">Source</a><a href="#method.from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(t: T) -> T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p> </div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#769-771">Source</a><a href="#impl-Into%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T<div class="where">where U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#779">Source</a><a href="#method.into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fn">into</a>(self) -> U</h4></section></summary><div class="docblock"><p>Calls <code>U::from(self)</code>.</p> <p>That is, this conversion is whatever the implementation of <code><a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for U</code> chooses to do.</p> </div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#814-816">Source</a><a href="#impl-TryFrom%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T<div class="where">where U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#818">Source</a><a href="#associatedtype.Error" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.never.html">!</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#821">Source</a><a href="#method.try_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fn">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.never.html">!</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#798-800">Source</a><a href="#impl-TryInto%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T<div class="where">where U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#802">Source</a><a href="#associatedtype.Error-1" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#805">Source</a><a href="#method.try_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fn">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details></div></section></div></main></body></html>