Skip to content

Enable direct canvas painting while color picker is open#325

Merged
tracygardner merged 1 commit intomainfrom
claude/color-picker-mesh-click-lKUUu
Feb 26, 2026
Merged

Enable direct canvas painting while color picker is open#325
tracygardner merged 1 commit intomainfrom
claude/color-picker-mesh-click-lKUUu

Conversation

@tracygardner
Copy link
Contributor

Summary

This PR adds the ability to directly paint on the canvas by clicking/tapping while the color picker is open, without requiring users to confirm the color selection first. It also improves UX by showing a crosshair cursor on the canvas when the picker is active.

Key Changes

  • Direct painting on canvas: Added click event listener to the render canvas that applies the color picker's current color directly to the canvas when clicked, even while the picker remains open
  • Exclude canvas from close logic: Implemented excludeFromClose callback in the color picker to prevent the picker from closing when clicking on the canvas itself
  • Visual feedback: Added color-picker-open class to body when picker opens/closes, enabling a crosshair cursor on the canvas via CSS
  • State tracking: Color picker now tracks isOpen state more reliably by adding/removing the body class in open() and close() methods

Implementation Details

  • The canvas click handler uses the picker's currentColor (live color) rather than waiting for confirmation via the "Use" button
  • Canvas coordinates are properly calculated using getCanvasXAndCanvasYValues() before applying color
  • The excludeFromClose option allows the color picker to remain open after canvas interactions, improving workflow efficiency
  • CSS cursor change provides clear visual indication that the canvas is interactive while the picker is open

https://claude.ai/code/session_01DAYassUFrMjCRWJQyiyQgG

When the colour picker is open, clicking or tapping on any mesh in the
3D scene now immediately applies the currently selected colour without
needing to press 'Use' first. The picker stays open so multiple meshes
can be painted in one session.

On mouse/pointer devices the crosshair cursor appears as soon as the
pointer moves off the colour picker popup onto the canvas (via a CSS
body class), rather than only after pressing 'Use'.

Implementation:
- colourpicker.js: add `excludeFromClose` callback option so callers
  can exempt specific elements (e.g. the canvas) from triggering the
  outside-click-to-close behaviour; add/remove `color-picker-open`
  body class on open/close for CSS cursor targeting
- gizmos.js: pass `excludeFromClose` that exempts #renderCanvas; add
  a persistent click handler on the canvas that applies the picker's
  live colour whenever the picker is open
- style.css: `body.color-picker-open #renderCanvas { cursor: crosshair }`

https://claude.ai/code/session_01DAYassUFrMjCRWJQyiyQgG
@tracygardner tracygardner merged commit c24d02d into main Feb 26, 2026
4 of 5 checks passed
@tracygardner tracygardner deleted the claude/color-picker-mesh-click-lKUUu branch February 26, 2026 14:48
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