Repository navigation
Conversation
The scene geometry used for cuts, fills and offset fills was imported from the object's own SVG (which already carries its full transform) and then translated so its top-left matched getBoundingRect(). That box includes the stroke and, for a rotated object, is the axis-aligned hull of the rotated box, so it is larger than the shape itself: rotated parts were cut several millimetres away from where the canvas draws them (about 7 mm for a 34 mm disc at 45°, up to 15 mm for larger parts), and unrotated ones by half the stroke width. Drop the re-alignment. Measured against Fabric's own geometry (each leaf's points through its absolute matrix), rects, ellipses, circles, polygons, curved paths, groups and nested groups now match within 0.03 mm at any angle, scale or mirror. The origin tests used a rect with Fabric's default 1 mm stroke, whose outline really is half the stroke inside left/top; they now use no stroke so the expected coordinates stay the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #17
Problem
Rotated shapes were cut several millimetres away from where the canvas draws them (about 7 mm for a 34 mm disc at 45°, up to 15 mm for larger parts), and unrotated ones by half the stroke width. Details and measurements in the issue.
Change
src/geometry/paperOps.ts:objectToScenePathItems,objectToSceneCompoundPathDataandobjectToScenePathDatano longer translate the imported geometry ontogetBoundingRect().toSVG()already carries the object's full transform, so the imported geometry is where the canvas draws it. These three functions feed line cuts, fills and offset fills. Booleans, convert-to-path and the rest do not go through them.Testing
src/geometry/paperOps.test.ts: rects rotated by 0°, 30°, 45°, 90° and 137°, and a rotated, scaled group, are cut where Fabric draws them (within 0.005 mm, the rounding oftoSVG()), for contours, fills and offset fills. All six tests fail without the fix.src/gcode/job.test.ts(device origin): the test rect used Fabric's default 1 mm stroke, whose outline really is half the stroke insideleft/top. It now has no stroke, so the expected coordinates are unchanged.generateJob(the plan used by the preview and for sending to the machine) for a circle rotated 45° and an L-shaped polygon rotated 40°. The cut path is now centred on the drawn shape (offset 0.000 / 0.001 mm, against 11.9 / 19.3 mm onmain). There are no console errors. Not run through the GRBL simulator: the change sits before G-code emission, and the emitted G-code follows the same plan.npm run typecheck,npm run test(485 tests),npm run buildandnpm run test:e2e(38 passed, 3 skipped) pass.Note: the X/Y fields of the shape properties still show the bounding box including the stroke, so with a thick stroke the cut now sits half a stroke inside the displayed X/Y, exactly where the outline is drawn.
🤖 Generated with Claude Code