Skip to content

Fix stamp tool cursor positioning to match anchor point#61

Open
bengotow wants to merge 1 commit intomasterfrom
claude/fix-stamp-tool-placement-Wb9Tq
Open

Fix stamp tool cursor positioning to match anchor point#61
bengotow wants to merge 1 commit intomasterfrom
claude/fix-stamp-tool-placement-Wb9Tq

Conversation

@bengotow
Copy link
Collaborator

Summary

Fixed the stamp tool to position dropped sprites at the cursor location by computing the drag offset based on the sprite's anchor point, matching the visual feedback shown in the cursor.

Changes

  • Import DEFAULT_APPEARANCE_INFO from sprite module for fallback appearance data
  • Refactored drag offset calculation to handle three cases:
    • Drag-and-drop: Use the offset stored in dataTransfer (existing behavior)
    • Stamp tool: Compute offset dynamically based on the sprite's anchor point and current scale
    • Default: Fall back to center-based offset for other tools
  • For stamp tool, resolve the correct appearance info by:
    • Looking up the anchor actor's character and appearance if stamping an actor
    • Looking up the character and its default appearance if stamping a character
    • Using DEFAULT_APPEARANCE_INFO as fallback
  • Calculate screen-space offset accounting for anchor position, cell size, and current zoom scale

Implementation Details

The stamp tool now computes dragLeft and dragTop as the distance from the sprite's top-left corner to its anchor center in screen pixels. This ensures that when a sprite is dropped, its anchor point aligns with the cursor position, matching the visual representation shown in the cursor preview.

The stamp tool was placing sprites off by one square because it used a
fixed offset (center of cell) instead of the sprite's actual anchor
point offset. This caused a mismatch between where the cursor showed
the sprite and where it was actually placed.

The fix computes the correct offset based on the stamp item's anchor
position, matching the cursor positioning in cursor-support.tsx.

https://claude.ai/code/session_01WC2Evn9xnmzidW5oGzbogY
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