Skip to content

Commit

Permalink
Merge pull request #74 from sorairolake/optimize-svg-output
Browse files Browse the repository at this point in the history
chore(svg): Reduce size of SVG output
  • Loading branch information
kennytm authored Sep 26, 2024
2 parents 85b51f5 + 1d0c477 commit c578416
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/render/svg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl<'a> RenderCanvas for Canvas<'a> {
r#"<svg xmlns="http://www.w3.org/2000/svg""#,
r#" version="1.1" width="{w}" height="{h}""#,
r#" viewBox="0 0 {w} {h}" shape-rendering="crispEdges">"#,
r#"<rect x="0" y="0" width="{w}" height="{h}" fill="{bg}"/>"#,
r#"<path d="M0 0h{w}v{h}H0z" fill="{bg}"/>"#,
r#"<path fill="{fg}" d=""#,
),
w = width,
Expand All @@ -68,7 +68,7 @@ impl<'a> RenderCanvas for Canvas<'a> {
}

fn draw_dark_rect(&mut self, left: u32, top: u32, width: u32, height: u32) {
write!(self.svg, "M{left} {top}h{width}v{height}H{left}V{top}").unwrap();
write!(self.svg, "M{left} {top}h{width}v{height}h-{width}z").unwrap();
}

fn into_image(mut self) -> String {
Expand Down
2 changes: 1 addition & 1 deletion src/test_annex_i_micro_qr_as_svg.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/test_annex_i_qr_as_svg.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c578416

Please sign in to comment.