[][src]Struct pikchr::Pikchr

pub struct Pikchr { /* fields omitted */ }

A rendered pikchr diagram

Pikchr renders diagrams as SVG. This SVG is a given width and height. The Pikchr derefs to the SVG string, or you can access it explicitly. The width and height are accessible as plain numbers.

Implementations

impl Pikchr[src]

pub fn render(
    source: &str,
    class: Option<&str>,
    flags: PikchrFlags
) -> Result<Pikchr, String>
[src]

Render some input pikchr source as an SVG

You can convert arbitrary pikchr source into an SVG using this function. The class name is optional, and the flags field controls the generation of errors. Since pikchr does not have a structured error format, the returned error is simply a string.

let image = Pikchr::render(r#"
arrow right 200% "Markdown" "Source"
box rad 10px "Markdown" "Formatter" "(markdown.c)" fit
arrow right 200% "HTML+SVG" "Output"
arrow <-> down 70% from last box.s
box same "Pikchr" "Formatter" "(pikchr.c)" fit"#,
     None, PikchrFlags::default())
    .unwrap();
assert!(image.contains("<svg"))

pub fn width(&self) -> isize[src]

Retrieve the width of this Pikchr

println!("Picture is {} pixels wide", pic.width());

pub fn height(&self) -> isize[src]

Retrieve the height of this Pikchr

println!("Picture is {} pixels tall", pic.height());

pub fn rendered(&self) -> &str[src]

Retrieve the rendered pikchr (same as dereferencing)

println!("Picture content:\n{}", pic.rendered());

Trait Implementations

impl Deref for Pikchr[src]

type Target = str

The resulting type after dereferencing.

impl Display for Pikchr[src]

impl Drop for Pikchr[src]

Auto Trait Implementations

impl RefUnwindSafe for Pikchr

impl !Send for Pikchr

impl !Sync for Pikchr

impl Unpin for Pikchr

impl UnwindSafe for Pikchr

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.