Skip to main content

Drawing

Struct Drawing 

Source
pub struct Drawing {
    pub page: P,
    pub layers: Vec<Layer>,
    pub link: Option<[f64; 4]>,
    pub text: Vec<TextRun>,
    pub annotations: Vec<Annotation>,
    pub sheet: Sheet,
    pub problems: Vec<Problem>,
    pub spec: Option<String>,
}

Fields§

§page: P

Page width and height, mm.

§layers: Vec<Layer>§link: Option<[f64; 4]>

The attribution link’s rectangle (x0, y0, x1, y1), mm.

§text: Vec<TextRun>§annotations: Vec<Annotation>

The annotations drawn, with what each states. Written to no file format.

§sheet: Sheet

The views and things drawn, for lint’s sheet checks. Written to no file format.

§problems: Vec<Problem>

What could not be drawn as planned (undrawn). Written to no file format.

§spec: Option<String>

The spec the drawing was made from (JSON), carried in the SVG’s metadata, the DXF’s opening comments and the PDF’s document information so the drawing can be resumed from the file alone.

Implementations§

Source§

impl Drawing

Source

pub fn svg(&self) -> String

The SVG: a page in millimetres, y up inside a flipping group, one group per layer, then the labels’ text, invisible.

Source

pub fn dxf(&self) -> Vec<u8> ⓘ

An editable R2013 DXF in millimetres at sheet size in model space.

Source

pub fn pdf(&self, fonts: &dyn Fn(&str) -> Option<Vec<u8>>) -> Vec<u8> ⓘ

The PDF: the page in points, each layer’s paths stroked (faces filled) in its style, the labels’ text invisible over them in the embedded fonts (looked up by file name in fonts), and the attribution link.

Source

pub fn pdf_pages( drawings: &[Drawing], fonts: &dyn Fn(&str) -> Option<Vec<u8>>, ) -> Vec<u8> ⓘ

One PDF page per drawing, in order, with the first drawing’s whole Spec embedded. A single drawing uses precisely the same objects and bytes as Self::pdf.

Source§

impl Drawing

Source

pub fn png(&self, dpi: f64) -> Result<Vec<u8>, String>

The PNG at dpi, or why there is none: a dpi that is not positive, or a page too large at it.

Source

pub fn png_region( &self, dpi: f64, region: Option<[f64; 4]>, ) -> Result<Vec<u8>, String>

Render a paper region directly, keeping the full drawing’s embedded Spec.

Trait Implementations§

Source§

impl Clone for Drawing

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Drawing

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Finish for T

Source§

fn finish(self)

Does nothing but move self, equivalent to drop.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.