Skip to content
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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

defer
Copy link

@defer defer commented Mar 5, 2025

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:
Before

After:
After

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.
Copy link
Owner

@georgslazdans georgslazdans left a 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`;
Copy link
Owner

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) => {
Copy link
Owner

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 => {
Copy link
Owner

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.

@georgslazdans georgslazdans changed the base branch from master to develop March 5, 2025 08:02
@georgslazdans
Copy link
Owner

Changed the default branch to be develop, so bumping the version and changelog can be ignored!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants