Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR bumps the Next2D Player version from 2.7.0 to 2.8.0 and adds fallback hit detection logic for shapes without graphics buffer data.
- Version updated to 2.8.0 across package.json and console output
- Implemented fallback rectangle path for hit testing shapes with empty graphics buffers
- Added comprehensive test coverage with 15 new test cases covering various scenarios including transformations, edge cases, and negative coordinates
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| package.json | Updated version from 2.7.0 to 2.8.0 |
| src/index.ts | Updated console log version string to 2.8.0 |
| packages/display/src/Shape/usecase/ShapeHitTestUseCase.ts | Added fallback hit detection for shapes without graphics buffer by creating a default rectangle path based on bounds |
| packages/display/src/Shape/usecase/ShapeHitTestUseCase.test.ts | Added 15 new test cases (test11-test25) covering hit detection scenarios without buffer, transformations, negative coordinates, and edge cases |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| hit_context.moveTo(0, 0); | ||
| hit_context.lineTo(width, 0); | ||
| hit_context.lineTo(width, height); | ||
| hit_context.lineTo(0, height); | ||
| hit_context.lineTo(0, 0); |
There was a problem hiding this comment.
The fallback rectangle path is using incorrect coordinates. The path starts at (0, 0) and extends to (width, height), but it should start at (xMin, yMin) and extend to (xMax, yMax) to correctly represent the shape's bounds.
For example, if a shape has xMin = -50, yMin = -50, xMax = 50, yMax = 50, the current code would create a rectangle from (0, 0) to (100, 100), but it should create a rectangle from (-50, -50) to (50, 50).
Suggested fix:
hit_context.moveTo(graphics.xMin, graphics.yMin);
hit_context.lineTo(graphics.xMax, graphics.yMin);
hit_context.lineTo(graphics.xMax, graphics.yMax);
hit_context.lineTo(graphics.xMin, graphics.yMax);
hit_context.lineTo(graphics.xMin, graphics.yMin);| hit_context.moveTo(0, 0); | |
| hit_context.lineTo(width, 0); | |
| hit_context.lineTo(width, height); | |
| hit_context.lineTo(0, height); | |
| hit_context.lineTo(0, 0); | |
| hit_context.moveTo(graphics.xMin, graphics.yMin); | |
| hit_context.lineTo(graphics.xMax, graphics.yMin); | |
| hit_context.lineTo(graphics.xMax, graphics.yMax); | |
| hit_context.lineTo(graphics.xMin, graphics.yMax); | |
| hit_context.lineTo(graphics.xMin, graphics.yMin); |
No description provided.