Skip to content

Feature/arrows#48

Merged
kimgh06 merged 3 commits into
mainfrom
feature/arrows
Sep 18, 2025
Merged

Feature/arrows#48
kimgh06 merged 3 commits into
mainfrom
feature/arrows

Conversation

@kimgh06

@kimgh06 kimgh06 commented Sep 18, 2025

Copy link
Copy Markdown
Contributor
  • show arrow in interaction canvas.
    • fix drawCursor function for performance & looking good.

…for improved rendering

- Adjusted JSON structure in renderPaths.json for better path and color management.
- Removed device pixel ratio scaling in CanvasRenderComponent for simplified canvas setup.
- Enhanced cursor drawing logic and improved handling of canvas references for better performance.
- Streamlined path rendering and cursor movement logic to enhance overall rendering efficiency.
- Replaced for-loop with while-loop for improved readability and performance in closed tile updates.
- Enhanced visibility management for closed tiles by streamlining the logic for setting visibility states.
- Improved clarity in variable naming for better understanding of the tile update process.
…context retrieval

- Renamed tile padding parameters to tilePadWidth and tilePadHeight for consistency.
- Simplified context retrieval function name from getContext to getCtx for clarity.
- Streamlined visibility management logic for closed tiles to enhance readability.
- Optimized tile edge snapping logic to utilize updated parameter names.
Copilot AI review requested due to automatic review settings September 18, 2025 12:59
@kimgh06 kimgh06 merged commit 92c85ad into main Sep 18, 2025
1 check passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request implements arrow display functionality in the interaction canvas and improves the drawCursor function for better performance and visual quality. The changes primarily focus on rendering enhancements and code optimization.

  • Adds arrow rendering at the end of drawn paths in the interaction canvas
  • Optimizes drawCursor function by removing device pixel ratio scaling and simplifying calculations
  • Refactors variable names for better consistency and readability

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/components/tilemap/index.tsx Renames tilePadding props for consistency, optimizes loops and conditional logic, and improves code structure
src/components/canvas/index.tsx Implements arrow rendering, removes device pixel ratio scaling, optimizes drawCursor function, and simplifies canvas setup
src/assets/renderPaths.json Updates cursor path geometry and simplifies the countColors array formatting

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

neighbor.gScore = tempG;
neighbor.heuristic = Math.abs(neighbor.x - target.x) + Math.abs(neighbor.y - target.y);
neighbor.fTotal = neighbor.gScore + neighbor.heuristic;
const tempG = nowNode.gScore + (isDiagonal ? 14 : 10);

Copilot AI Sep 18, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The magic numbers 14 and 10 should be defined as named constants to clarify their purpose in the A* pathfinding algorithm. Consider adding comments explaining that these represent the cost of diagonal vs. orthogonal movement.

Copilot uses AI. Check for mistakes.
const [lastPointX, lastPointY] = [(last.x + beforeLast.x) / 2, (last.y + beforeLast.y) / 2];
const pathRotate = Math.PI + Math.atan2(last.y - beforeLast.y, last.x - beforeLast.x);
interactionCtx.lineTo(lastPointX, lastPointY);
drawCursor(interactionCtx, lastPointX - tileSize / 2, lastPointY - tileSize / 2, cursorColor, 0, pathRotate, 0.6);

Copilot AI Sep 18, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The magic number 0.6 for the cursor scale should be defined as a named constant to improve code readability and maintainability.

Copilot uses AI. Check for mistakes.
Comment on lines +378 to +386
const texture = numberTextures.get(+content);
if (!texture) continue;
// Number sprite elements
if (+content > 0) {
const num = +content;
const texture = numberTextures.get(num);
if (texture) {
const keyNum = `num${num}${tileSize}`;
const baseNum = numberCache.get(keyNum) ?? <Sprite cullable={true} roundPixels={true} eventMode="none" texture={texture} anchor={0.5} />;
numberCache.set(keyNum, baseNum);
const { width, height } = texture;
const scale = { x: w / width, y: h / height };
textElements[textIdx++] = cloneElement(baseNum, { key: typeKeyBase + 4, x: startX + tileSize / 2, y: startY + tileSize / 2, scale });
}
}
const keyNum = `num${+content}${tileSize}`;
const baseNum = numberCache.get(keyNum) ?? <Sprite cullable={true} roundPixels={true} eventMode="none" texture={texture} anchor={0.5} />;
numberCache.set(keyNum, baseNum);
const { width, height } = texture;
const scale = { x: w / width, y: h / height };
textElements[textIdx++] = cloneElement(baseNum, { key: typeKeyBase + 4, x: startX + tileSize / 2, y: startY + tileSize / 2, scale });

Copilot AI Sep 18, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The number texture logic assumes content can be converted to a positive number, but this code block is reached for all tile content types. This should be wrapped in a condition to check if the content represents a valid number (1-8) to prevent unnecessary processing.

Copilot uses AI. Check for mistakes.
@kimgh06 kimgh06 deleted the feature/arrows branch December 23, 2025 12:11
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