-
-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dxf: Center object in (0, 0) #11
base: develop
Are you sure you want to change the base?
Conversation
Since most cad usages will have pieces centered in the origin axis and only one outline is exported in the dxf, it makes sense to also center the outline in the axis. This works by introducing a modification centerOnOrigin that computes a bounding box and translates polygon points according to its center.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice, You should receive a cookie for the very first PR to this repository! 🍪
For the sake of consistency, this should also be applied to the SVG export - center the points on origin instead of just centering the paper.
Also, every change pushed to master will redeploy the app. Would be nice to bump version in package.json
and add an entry in the changelog app/changelog/page.mdx
.
Will add a contributions info along with a develop
branch to test changes and handle the changelog myself before merging into master. There is a single UI test that will break with the SVG changes, but that can be ignored for now.
@@ -32,7 +32,7 @@ const polyLineOf = (points: Point[], paperDimensions: PaperDimensions) => { | |||
|
|||
const dxfPointOf = (point: Point, paperDimensions: PaperDimensions) => { | |||
const { x, y } = point; | |||
return `10\n${x}\n20\n${paperDimensions.height - y}\n`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was added to align the output with what is seen in the calibration screen. This could be achieved with the existing function _mirrorPointsOnXAxis
. That function probably needs a bit clearer name like _invertYPoints
.
@@ -32,7 +32,7 @@ const polyLineOf = (points: Point[], paperDimensions: PaperDimensions) => { | |||
|
|||
const dxfPointOf = (point: Point, paperDimensions: PaperDimensions) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If paperDimensions
is no longer used, then it should be removed here and all along the call chain.
height: number; | ||
}; | ||
|
||
const _boundingRect = (contour: ContourPoints): BoundingRect => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There already is a function _findPathBounds
, although it only gets the min max values, it would be nice to reuse it here.
Changed the default branch to be |
Since most cad usages will have pieces centered in the origin axis and only one outline is exported in the dxf, it makes sense to also center the outline in the axis.
This works by introducing a modification centerOnOrigin that computes a bounding box and translates polygon points according to its center.
Before:

After:
