Skip to content

Commit

Permalink
fix inner bbox
Browse files Browse the repository at this point in the history
  • Loading branch information
CGQAQ committed Jan 29, 2024
1 parent d8fa262 commit cc807e1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
12 changes: 6 additions & 6 deletions __test__/wasm.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,12 +430,12 @@ test('should get svg bbox with stroke', (t) => {
const resvg = new Resvg(svg)
const bbox = resvg.getBBox()
t.not(bbox, undefined)
// if (bbox) {
// t.is(bbox.width, 116.70712280273438)
// t.is(bbox.height, 90)
// t.is(bbox.x, -21.707120895385742)
// t.is(bbox.y, 5)
// }
if (bbox) {
t.is(bbox.width, 116.70712280273438)
t.is(bbox.height, 90)
t.is(bbox.x, -21.707120895385742)
t.is(bbox.y, 5)
}

const innerBBox = resvg.innerBBox()
t.not(innerBBox, undefined)
Expand Down
5 changes: 3 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use pathfinder_content::outline::{Contour, Outline};
use pathfinder_content::stroke::{LineCap, LineJoin, OutlineStrokeToFill, StrokeStyle};
use pathfinder_geometry::rect::RectF;
use pathfinder_geometry::vector::Vector2F;
use resvg::tiny_skia::PathSegment;
use resvg::tiny_skia::{PathSegment, Transform};
use resvg::usvg::TreePostProc;
use resvg::{
tiny_skia::{Pixmap, Point},
Expand Down Expand Up @@ -412,7 +412,7 @@ impl Resvg {

impl Resvg {
fn node_bbox(&self, node: &usvg::Node) -> Option<RectF> {
let transform = node.abs_transform();
let mut transform = Transform::identity();
let bbox = match node {
usvg::Node::Path(p) => {
let no_fill = p.fill.is_none()
Expand Down Expand Up @@ -488,6 +488,7 @@ impl Resvg {
Some(outline.bounds())
}
usvg::Node::Group(g) => {
transform = g.transform;
let clippath = if let Some(ref clippath) = g
.clip_path
.as_ref()
Expand Down
Binary file modified wasm/index_bg.wasm
Binary file not shown.

0 comments on commit cc807e1

Please sign in to comment.