-
Notifications
You must be signed in to change notification settings - Fork 13
fix: implement true grid pattern for Grid and Cross brushes #118
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
Merged
+136
−45
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
The Grid and Cross brush patterns in Arma 3 create a crosshatch pattern with both horizontal and vertical lines. The previous implementation only created stripes in one direction. Changes: - Add custom L.GridPattern class that draws both horizontal and vertical lines to create a true grid pattern - Update "grid" and "cross" brush cases to use L.GridPattern - Adjust pattern weight/spacing for better visual match This also includes previous fixes: - Add ELLIPSE to updateRender method - Add defensive size array checks
- Fix GridPattern to set path 'd' attribute during shape creation - Add defensive check in _update for missing shapes - Fix polygon options merging to properly include fillPattern - Increase pattern and fill opacity for better visibility - Add case-insensitive brush matching (GRID, CROSS) - Add console.debug statements to trace pattern creation flow
Canvas renderer doesn't support SVG patterns. Created a dedicated SVG renderer that is used only for ELLIPSE and RECTANGLE shapes with brush patterns. The rest of the map still uses Canvas for performance.
- Remove unused _update method from L.GridPattern - Remove unused L.gridPattern factory function - Simplify show() method (all branches did same thing) - Combine ELLIPSE and RECTANGLE into single branch - Remove debug console.log for RECTANGLE conversion
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.
Summary
Fixes Grid and Cross brush patterns to display correctly on ELLIPSE and RECTANGLE markers, matching Arma 3's in-game appearance with a crosshatch pattern overlay.
Problem
Pattern not visible: The map uses
preferCanvas: truefor performance, but Canvas rendering doesn't support SVG patterns. The patterns were being created but never displayed.Wrong pattern type: The previous implementation used
L.StripePatternwhich only draws lines in one direction. Grid/Cross brushes need both horizontal and vertical lines.Solution
1. SVG Renderer for Patterned Shapes
Created a dedicated SVG renderer (
window.svgRenderer) that's used only for shapes with pattern fills:2. Custom GridPattern Class
Created
L.GridPatternthat draws both horizontal and vertical lines with a colored background:3. L.SVG._updateStyle Patch
Patched the SVG renderer to apply pattern fills after style updates:
Visual Result
Also Included
updateRendermethod (was only RECTANGLE)this._sizearray accessTest Plan