Skip to content

Conversation

@TKanX
Copy link
Member

@TKanX TKanX commented Aug 16, 2025

Summary:

Introduces a new public method, getPieceIndexAt(x, y), to the Renderer. This method provides a direct way to get a piece's index from canvas coordinates, enabling developers to build custom interactions like tooltips or hover effects without being tied to the built-in event system. It effectively serves as the public-facing reverse operation to getPieceCoordinates, enhancing the library's flexibility.

Changes:

  • Added Public Method:

    • Implemented renderer.getPieceIndexAt(x, y) to retrieve a piece index from canvas coordinates. This method leverages the internal hitmap for efficient lookups, returning -1 if no piece is found.
  • API Documentation:

    • Added comprehensive documentation for the new getPieceIndexAt method in API.md, including a description, parameter details, and a clear usage example.
    • Updated the Table of Contents to include the new method.

@TKanX TKanX self-assigned this Aug 16, 2025
@TKanX TKanX added the documentation 📖 Improvements or additions to documentation label Aug 16, 2025
Copilot AI review requested due to automatic review settings August 16, 2025 08:13
@TKanX TKanX added the enhancement ✨ New feature or request label Aug 16, 2025
@TKanX TKanX linked an issue Aug 16, 2025 that may be closed by this pull request
2 tasks
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a new public method getPieceIndexAt(x, y) to the Renderer class that allows developers to retrieve a piece's index from canvas coordinates. This enables custom interactions like tooltips and hover effects without relying on the built-in event system.

  • Added getPieceIndexAt method to the Renderer class
  • Updated API documentation with comprehensive details and usage examples
  • Updated table of contents to include the new method

Reviewed Changes

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

File Description
src/renderer.js Implements the new getPieceIndexAt method using internal hitmap lookup
docs/API.md Adds complete documentation for the new method and updates TOC structure

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

…y return value

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@TKanX TKanX merged commit 813d7b0 into main Aug 16, 2025
8 checks passed
@TKanX TKanX deleted the feature/52-implement-getpieceindexat-method-in-renderer branch August 16, 2025 08:35
@TKanX TKanX changed the title feat(renderer): Implement getPieceIndexAt method feat(renderer): Implement getPieceIndexAt Method Aug 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation 📖 Improvements or additions to documentation enhancement ✨ New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement getPieceIndexAt Method in Renderer

2 participants