Skip to content

Commit

Permalink
Clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurenzV committed Jul 31, 2023
1 parent b0ca3b8 commit 1b86cdf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 31 deletions.
28 changes: 1 addition & 27 deletions src/render/gradient.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::rc::Rc;

use pdf_writer::types::{MaskType, ShadingType};
use pdf_writer::{Content, Filter, Finish, Name, PdfWriter, Ref};
use pdf_writer::types::{MaskType, ShadingType};
use usvg::{NonZeroRect, NormalizedF32, Paint, StopOffset, Transform, Units};

use crate::util::context::Context;
Expand Down Expand Up @@ -70,22 +70,6 @@ pub fn create_shading_soft_mask(
}
}

pub fn create_shading(
paint: &Paint,
parent_bbox: &NonZeroRect,
writer: &mut PdfWriter,
ctx: &mut Context,
) -> (Rc<String>, Transform) {
let properties = GradientProperties::try_from_paint(paint).unwrap();
let transform = (if properties.units == Units::ObjectBoundingBox {
Transform::from_bbox(*parent_bbox)
} else {
Transform::default()
})
.pre_concat(properties.transform);
(shading(&properties, writer, ctx, false), transform)
}

fn shading_pattern(
properties: &GradientProperties,
parent_bbox: &NonZeroRect,
Expand Down Expand Up @@ -165,16 +149,6 @@ fn shading_soft_mask(
ctx.deferrer.add_graphics_state(gs_ref)
}

fn shading(
properties: &GradientProperties,
writer: &mut PdfWriter,
ctx: &mut Context,
use_opacities: bool,
) -> Rc<String> {
let shading_function = shading_function(properties, writer, ctx, use_opacities);
ctx.deferrer.add_shading(shading_function)
}

fn shading_function(
properties: &GradientProperties,
writer: &mut PdfWriter,
Expand Down
11 changes: 7 additions & 4 deletions src/render/path.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
use pdf_writer::{Content, Finish, PdfWriter};
use pdf_writer::types::ColorSpaceOperand;
use pdf_writer::types::ColorSpaceOperand::Pattern;
use pdf_writer::{Content, Finish, PdfWriter};
use usvg::tiny_skia_path::PathSegment;
use usvg::{Fill, FillRule, Node, Opacity, Paint, PaintOrder};
use usvg::{Path, Visibility};
use usvg::{Stroke, Transform};
use usvg::tiny_skia_path::PathSegment;

use crate::render::{gradient, pattern};
use crate::util::context::Context;
use crate::util::helper::{ColorExt, LineCapExt, LineJoinExt, NameExt, plain_bbox, plain_bbox_without_default, SRGB, TransformExt};
use crate::util::helper::{
plain_bbox, plain_bbox_without_default, ColorExt, LineCapExt, LineJoinExt, NameExt,
TransformExt, SRGB,
};

/// Render a path into a content stream.
pub fn render(
Expand Down Expand Up @@ -175,7 +178,7 @@ pub fn fill(
}
}

pub fn draw_path(path_data: impl Iterator<Item=PathSegment>, content: &mut Content) {
pub fn draw_path(path_data: impl Iterator<Item = PathSegment>, content: &mut Content) {
// Taken from resvg
fn calc(n1: f32, n2: f32) -> f32 {
(n1 + n2 * 2.0) / 3.0
Expand Down

0 comments on commit 1b86cdf

Please sign in to comment.