-
-
Notifications
You must be signed in to change notification settings - Fork 16
Feature/constants refactoring #141
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
Draft
Dexus
wants to merge
10
commits into
main
Choose a base branch
from
feature/constants-refactoring
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
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
…tions - Created new Polygon class in main/util/polygon.ts as modern replacement for array-based polygons - Uses existing Point class for type-safe coordinate handling - Implements all commonly used polygon operations from geometryutil.js: - Geometric calculations: area(), bounds(), centroid(), perimeter() - Spatial queries: contains() with point-in-polygon testing - Transformations: translate(), rotate(), scale() with immutable and in-place variants - Utility methods: isRectangle(), reverse(), winding direction control - Provides conversion methods for legacy array format and Clipper integration - Includes static factory methods for creating rectangles and circles - Maintains compatibility with existing offsetx/offsety and children properties - Supports both immutable operations (return new instances) and in-place modifications
- Updated HullPolygon.ts to accept both new Polygon class and legacy Point[] arrays - Added backwards compatibility with PolygonArray type alias - Modified all static methods to handle both polygon types: - area(): delegates to Polygon.area() when possible - centroid(): delegates to Polygon.centroid() when possible - hull(): returns new Polygon instance instead of Point[] - contains(): uses Polygon.contains() with null-to-false conversion - length(): delegates to Polygon.perimeter() when possible - Maintains full backwards compatibility while enabling new Polygon class usage 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Updated key polygon functions in geometryutil.js to use new Polygon class: - getPolygonBounds(): delegates to polygon.bounds() when available - pointInPolygon(): delegates to polygon.contains() when available - polygonArea(): delegates to polygon.area() when available - isRectangle(): delegates to polygon.isRectangle() when available - rotatePolygon(): delegates to polygon.rotate() when available - Added global window export to polygon.ts for JavaScript compatibility - Maintains full backwards compatibility with array-based polygon format - Functions automatically detect Polygon class instances and use optimized methods 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Added Polygon class import to deepnest.js - Updated getHull() function to handle both Polygon instances and arrays - Added instanceof checks to use Polygon methods when available - Maintains backwards compatibility with existing array-based polygon format - HullPolygon.hull() results are converted to arrays for consistency with existing code 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Added Polygon class import to background.js - Updated getHull() function to handle Polygon instances: - Uses HullPolygon.hull() directly for Polygon objects - Converts results to arrays for compatibility with existing code - Updated rotatePolygon() function to handle Polygon instances: - Uses Polygon.rotate() method when available - Preserves exact property from original points - Maintains children handling for nested polygons - Maintains full backwards compatibility with array-based polygon format 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Added Polygon class import to svgparser.js
- Updated polygonify() method to return Polygon instances:
- Converts array of {x, y} points to Point instances
- Creates and returns new Polygon from Point array
- Maintains all existing SVG element support (rect, circle, ellipse, path, polygon, polyline)
- Preserves existing coincident point removal logic
- SVG parsing now directly produces Polygon objects ready for nesting operations
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Re-added Vector import and implemented proper vector-based operations - Added getEdgeNormal() method to get perpendicular edge vectors - Added getEdgeVector() method to get edge direction vectors - isRectangle() method already uses Vector through Point.to() for dot products - Enhanced geometric capabilities with proper vector mathematics - Fixed unused import issue identified in code review 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add GEOMETRIC_TOLERANCE for floating-point comparisons - Add angle conversion constants (DEG_TO_RAD, RAD_TO_DEG) - Add mathematical constants (TWO_PI) - Add default values for geometric operations - Add configuration constants (DEFAULT_CLIPPER_SCALE)
- Replace TOL constant with GEOMETRIC_TOLERANCE in polygon.ts and vector.ts - Replace angle conversion calculations with DEG_TO_RAD in polygon.ts and matrix.ts - Replace 2 * Math.PI with TWO_PI in polygon.ts - Replace hardcoded 32 with DEFAULT_CIRCLE_SEGMENTS in polygon.ts - Replace hardcoded 10000000 with DEFAULT_CLIPPER_SCALE in test file - Remove duplicate constant definitions across files
- Add constants.js for JavaScript compatibility with centralized constants - Update geometryutil.js to use GEOMETRIC_TOLERANCE, DEG_TO_RAD, and RAD_TO_DEG - Update deepnest.js to use DEFAULT_CLIPPER_SCALE throughout - Update background.js to use DEFAULT_CLIPPER_SCALE for all clipper operations - Update svgparser.js to use RAD_TO_DEG and TWO_PI constants - Add constants.js script loading to index.html and background.html - Ensure backward compatibility with fallback values in geometryutil.js
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.
No description provided.