microsoft / microsoft/maker.js
Unexpected subtract behaviour
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 302
- Avg merge
- 21h 28m
- Merged PRs (30d)
- 5
Description
Version 0.17 (NPM)
While using this library I stumbled upon the following unexpected result after subtracting a square model from two concentric circles:

The result should be:

Code to reproduce in the playground:
var makerjs = require('makerjs');
var rectangle = {
paths: {
top: new makerjs.paths.Line([-84, 226], [-82, -7]),
bottom: new makerjs.paths.Line([32.5,227], [34.5, -6]),
left: new makerjs.paths.Line([32.5, 227], [-84, 226]),
right: new makerjs.paths.Line([-82,-7], [34.5,-6])
}
};
var concentricCirles = {
paths: {
outerCircle: new makerjs.paths.Circle([0.5, 2], 194.005),
innerCircle: new makerjs.paths.Circle([1.5, -0], 162)
}
};
var cut = makerjs.model.combineSubtraction(concentricCirles, rectangle);
var svg = makerjs.exporter.toSVG(cut);
document.write(svg);
When making a straight rectangle, problem seems to disappear:
var rectangle = {
paths: {
top: new makerjs.paths.Line([-75, 226], [-75, -5]),
bottom: new makerjs.paths.Line([35,225], [35, -5]),
left: new makerjs.paths.Line([35, 225], [-75, 225]),
right: new makerjs.paths.Line([-75,-5], [34.5,-5])
}
};
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the supplied playground reproduction with makerjs.model.combineSubtraction on the concentric circles and skewed rectangle, then inspect the subtraction and SVG export path. Compare its output with the expected image and use the straight-rectangle variant as a control; done when the skewed rectangle subtraction produces the expected result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100