pub struct Px(pub usize);
Expand description
Scale in pixels
Tuple Fields§
§0: usize
Implementations§
source§impl Px
impl Px
sourcepub fn into_pt(self, dpi: f32) -> Pt
pub fn into_pt(self, dpi: f32) -> Pt
Examples found in repository?
examples/svg.rs (line 25)
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
fn main() {
let (doc, page1, layer1) =
PdfDocument::new("printpdf graphics test", Mm(210.0), Mm(297.0), "Layer 1");
let current_layer = doc.get_page(page1).get_layer(layer1);
let svg = Svg::parse(SVG).unwrap();
let rotation_center_x = Px((svg.width.0 as f32 / 2.0) as usize);
let rotation_center_y = Px((svg.height.0 as f32 / 2.0) as usize);
let reference = svg.into_xobject(¤t_layer);
for i in 0..10 {
reference.clone().add_to_layer(
¤t_layer,
SvgTransform {
rotate: Some(SvgRotation {
angle_ccw_degrees: i as f32 * 36.0,
rotation_center_x: rotation_center_x.into_pt(300.0),
rotation_center_y: rotation_center_y.into_pt(300.0),
}),
translate_x: Some(Mm(i as f32 * 20.0 % 50.0).into()),
translate_y: Some(Mm(i as f32 * 30.0).into()),
..Default::default()
},
);
}
let pdf_bytes = doc.save_to_bytes().unwrap();
std::fs::write("test_svg.pdf", &pdf_bytes).unwrap();
}
Trait Implementations§
source§impl AddAssign for Px
impl AddAssign for Px
source§fn add_assign(&mut self, other: Self)
fn add_assign(&mut self, other: Self)
Performs the
+=
operation. Read moresource§impl Ord for Px
impl Ord for Px
source§impl PartialOrd for Px
impl PartialOrd for Px
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl SubAssign for Px
impl SubAssign for Px
source§fn sub_assign(&mut self, other: Self)
fn sub_assign(&mut self, other: Self)
Performs the
-=
operation. Read moreimpl Copy for Px
impl Eq for Px
impl StructuralEq for Px
impl StructuralPartialEq for Px
Auto Trait Implementations§
impl RefUnwindSafe for Px
impl Send for Px
impl Sync for Px
impl Unpin for Px
impl UnwindSafe for Px
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more