@@ -130,13 +130,8 @@ fn render_path_partial(
130130 // Soft Mask. Because we want the masks to intersect instead, we wrap
131131 // the path in a transparency group instead.
132132 let mut xobj_content = if let Some ( alpha_func) = fill_g_alpha {
133- let smask_form_ref = prep_shading (
134- alpha_func,
135- fill_gradient. as_ref ( ) . unwrap ( ) ,
136- bbox,
137- writer,
138- ctx,
139- ) ;
133+ let smask_form_ref =
134+ prep_shading ( alpha_func, fill_gradient. as_ref ( ) . unwrap ( ) , bbox, writer, ctx) ;
140135
141136 Some ( start_wrap ( smask_form_ref, content, ctx) )
142137 } else if let Some ( alpha_func) = stroke_g_alpha {
@@ -267,11 +262,7 @@ fn render_path_partial(
267262
268263 draw_path ( & path. data . 0 , path. transform , content, & ctx. c ) ;
269264
270- match (
271- path. fill . as_ref ( ) . map ( |f| f. rule ) ,
272- fill,
273- path. stroke . is_some ( ) && stroke,
274- ) {
265+ match ( path. fill . as_ref ( ) . map ( |f| f. rule ) , fill, path. stroke . is_some ( ) && stroke) {
275266 ( Some ( FillRule :: NonZero ) , true , true ) => content. fill_nonzero_and_stroke ( ) ,
276267 ( Some ( FillRule :: EvenOdd ) , true , true ) => content. fill_even_odd_and_stroke ( ) ,
277268 ( Some ( FillRule :: NonZero ) , true , false ) => content. fill_nonzero ( ) ,
@@ -367,13 +358,12 @@ fn prep_shading(
367358 shading. shading_type ( gradient. shading_type ) ;
368359 shading. color_space ( ) . d65_gray ( ) ;
369360 shading. function ( alpha_func) ;
370- shading. coords ( gradient. transformed_coords ( & ctx. c , bbox) . into_iter ( ) . take (
371- if gradient. shading_type == ShadingType :: Axial {
372- 4
373- } else {
374- 6
375- } ,
376- ) ) ;
361+ shading. coords (
362+ gradient
363+ . transformed_coords ( & ctx. c , bbox)
364+ . into_iter ( )
365+ . take ( if gradient. shading_type == ShadingType :: Axial { 4 } else { 6 } ) ,
366+ ) ;
377367 shading. extend ( [ true , true ] ) ;
378368 shading. finish ( ) ;
379369
@@ -452,11 +442,7 @@ fn prep_pattern(
452442 } else if pattern. content_units == Units :: ObjectBoundingBox {
453443 let viewbox = ViewBox {
454444 rect : usvg:: Rect :: new ( 0.0 , 0.0 , 1.0 , 1.0 ) . unwrap ( ) ,
455- aspect : AspectRatio {
456- defer : false ,
457- align : Align :: None ,
458- slice : false ,
459- } ,
445+ aspect : AspectRatio { defer : false , align : Align :: None , slice : false } ,
460446 } ;
461447
462448 CoordToPdf :: new ( ( bbox. width ( ) , bbox. height ( ) ) , ctx. c . dpi ( ) , viewbox, None )
@@ -522,14 +508,8 @@ impl Render for usvg::Group {
522508
523509 // Every group is an isolated transparency group, it needs to be painted
524510 // onto its own canvas.
525- let mut form = form_xobject (
526- writer,
527- group_ref,
528- & child_content,
529- pdf_bbox,
530- ctx. compress ,
531- true ,
532- ) ;
511+ let mut form =
512+ form_xobject ( writer, group_ref, & child_content, pdf_bbox, ctx. compress , true ) ;
533513
534514 let mut resources = form. resources ( ) ;
535515 ctx. pop ( & mut resources) ;
@@ -577,12 +557,10 @@ impl Render for usvg::Image {
577557 let image_ref = ctx. alloc_ref ( ) ;
578558
579559 #[ cfg( any( feature = "png" , feature = "jpeg" , feature = "gif" ) ) ]
580- let set_image_props = |
581- image : & mut ImageXObject ,
582- raster_size : & mut Option < ( u32 , u32 ) > ,
583- decoded : & DynamicImage ,
584- grey : bool ,
585- | {
560+ let set_image_props = |image : & mut ImageXObject ,
561+ raster_size : & mut Option < ( u32 , u32 ) > ,
562+ decoded : & DynamicImage ,
563+ grey : bool | {
586564 let color = decoded. color ( ) ;
587565 * raster_size = Some ( ( decoded. width ( ) , decoded. height ( ) ) ) ;
588566 image. width ( decoded. width ( ) as i32 ) ;
@@ -871,11 +849,7 @@ impl Gradient {
871849 c : & CoordToPdf ,
872850 bbox : usvg:: Rect ,
873851 ) -> [ f32 ; 6 ] {
874- let max = if bbox. width( ) > bbox. height( ) {
875- bbox. width( )
876- } else {
877- bbox. height( )
878- } ;
852+ let max = if bbox. width ( ) > bbox. height ( ) { bbox. width ( ) } else { bbox. height ( ) } ;
879853
880854 let coords = if self . transform_coords {
881855 let ( x1, y1) = c. point ( (
@@ -897,22 +871,13 @@ impl Gradient {
897871 } else {
898872 let ( x1, y1) = c. point ( ( self . coords [ 0 ] , self . coords [ 1 ] ) ) ;
899873 let ( x2, y2) = c. point ( ( self . coords [ 2 ] , self . coords [ 3 ] ) ) ;
900- [
901- x1,
902- y1,
903- x2,
904- y2,
905- c. px_to_pt( self . coords[ 4 ] ) ,
906- c. px_to_pt( self . coords[ 5 ] ) ,
907- ]
874+ [ x1, y1, x2, y2, c. px_to_pt ( self . coords [ 4 ] ) , c. px_to_pt ( self . coords [ 5 ] ) ]
908875 } ;
909876
910877 if self . shading_type == ShadingType :: Axial {
911878 [ coords[ 0 ] , coords[ 1 ] , coords[ 2 ] , coords[ 3 ] , 0.0 , 0.0 ]
912879 } else {
913- [
914- coords[ 0 ] , coords[ 1 ] , coords[ 4 ] , coords[ 2 ] , coords[ 3 ] , coords[ 5 ] ,
915- ]
880+ [ coords[ 0 ] , coords[ 1 ] , coords[ 4 ] , coords[ 2 ] , coords[ 3 ] , coords[ 5 ] ]
916881 }
917882 }
918883}
0 commit comments