fix: Color Picker resolves blend modes when sampling canvas color#8
Draft
Copilot wants to merge 2 commits into
Draft
fix: Color Picker resolves blend modes when sampling canvas color#8Copilot wants to merge 2 commits into
Copilot wants to merge 2 commits into
Conversation
1 task
…pling Previously, getColorAtCoordinate used stage.toCanvas() which does not apply CSS mix-blend-mode set on layer canvas elements. This caused the color picker to return raw layer colors instead of the visually composited result. The fix manually composites each visible Konva stage layer in order, reading the CSS mix-blend-mode from the underlying HTML canvas element and mapping it to the equivalent Canvas 2D globalCompositeOperation (only 'normal' -> 'source-over' needs remapping; all others match). Device pixel ratio is accounted for when converting CSS coordinates to physical canvas pixel coordinates. Bounds checking is also added. Agent-Logs-Url: https://github.com/dunkeroni/InvokeAI/sessions/5c74db51-8269-4ad8-80d5-c40b0affeb70 Co-authored-by: dunkeroni <3298737+dunkeroni@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix color picker to resolve blend mode correctly
fix: Color Picker resolves blend modes when sampling canvas color
May 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The color picker was returning raw layer pixel values, ignoring CSS
mix-blend-modeapplied to raster layer canvases. As shown in the screenshot above, hovering over the visually black multiply-blended intersection returnedR:235 G:39 B:39(the raw red layer color) instead of the composited result.Root cause:
getColorAtCoordinateused Konva'sstage.toCanvas(), which renders layers via Canvas 2D API and does not apply CSSmix-blend-mode— a browser compositor-level property set on the HTML canvas elements byCanvasEntityAdapterRasterLayer.syncGlobalCompositeOperation.Fix (
konva/util.ts—getColorAtCoordinate):stage.toCanvas()with manual layer-by-layer compositing into a 1×1 offscreen canvasstage.getLayers()in draw order; skip invisible layers (preserves existing background-hide behavior)htmlCanvas.style.mixBlendModefrom each layer's underlying_canvaselement (same internal API pattern already used inCanvasEntityAdapterRasterLayer)normal→source-over; all other CSS blend mode names are identical to Canvas 2DglobalCompositeOperationvalueswindow.devicePixelRatiofor HiDPI correctnessdrawImagewith bounds check on source coordinatesRelated Issues / Discussions
QA Instructions
Merge Plan
Checklist
What's Newcopy (if doing a release after this PR)