Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix,feat: canvas followups 8 #6858

Merged
merged 19 commits into from
Sep 15, 2024
Merged

Conversation

psychedelicious
Copy link
Collaborator

Summary

Fixes

  • Fix: Doing almost anything w/ an IP adapter errors
  • Fix: Disable the transformer while canvas is busy, preventing accidentally moving layers during staging or other operations
  • Fix: Cursor sometimes disappears or is unresponsive during staging
  • Fix: Bbox sometimes not interactable after staging
  • Fix: Do not floor stage coordinates when setting thing (I don't think this actually had any functional impact)
  • Fix: Wonky layouting for overlay alerts
  • Fix: Output only masked regions was inverted
  • Fix: Checkerboard background slightly larger than canvas (it is now rendered on the canvas instead of as a DOM element)
  • Fix: Progressive image quality degradation

Enhancements

  • Feat: Move canvas reset button out of the settings popover
  • Feat: Bbox overlay (adds dark overlay outside the bbox)
  • Feat: More detailed repr outputs for all classes
  • Feat: Preserve mask (i.e. inverted inpaint mask)
  • Feat: Middle-mouse click on any image opens it in new tab
  • Feat: Use Phosphor icons for all icons (except discord and GH logos)
  • Feat: Rename Generation tab to Canvas
  • Feat: Diff icons for canvas context menu

Internal

  • Internal: Cleanup some use of nanostores

Related Issues / Discussions

Discord & offline discussion.

QA Instructions

Try things out.

Merge Plan

I'll do an alpha release.

Checklist

  • The PR has a short but descriptive title, suitable for a changelog
  • Tests added / updated (if applicable)
  • Documentation added / updated (if applicable)

Need a to track a few more things to ensure we update the cursor correctly in all situations.
There were some scattered places where we used other icon packs. Changed all to use phosphor icons for consistency.
The checkerboard background was rendered as a separate DOM element that stretched to fill the canvas container.

While the canvas width and height are always integers, this background element could have non-integer dimensions, depending on panel sizes.As a result, it could be slightly larger than the canvas, introducing a fine border around the canvas.

This is purely a visual issue, but it's very noticeable when you use the bbox overlay. It also can be noticed with masks that extend beyond the edge of the visible canvas.

- Refactor the checkerboard background to be rendered by the canvas instead of as a DOM element, resolving the issue.
- Add a helper method to get the scaled rect of the stage, updating a few places where we need such a rect.
- Rename `CanvasStageModule.getScaledPixels` method to `unscale`, clarifying its purpose.
The HTML Canvas context has an `imageSmoothingEnabled` property which defaults to `true`. This causes the browser canvas API to, well, apply image smoothing - everything gets antialiased when drawn.

This is, of course, problematic when our goal is to be pixel-perfect. When the same image is drawn multiple times, we get progressive image degradation.

In `CanvasEntityObjectRenderer.cloneObjectGroup()`, where we use Konva's `Node.cache()` method to create a canvas from the entity's objects. Here, we were not setting `imageSmoothingEnabled` to false. This method is used very often by the compositor and we end up feeding back antialiased versions of the image data back into the canvas or generation backend.

Disabling smoothing here appears to fix the issue. I've also disabled image smoothing everywhere else we interact with a canvas rendering context.
@github-actions github-actions bot added the frontend PRs that change frontend files label Sep 15, 2024
@psychedelicious psychedelicious merged commit d50abd8 into main Sep 15, 2024
14 checks passed
@psychedelicious psychedelicious deleted the psyche/feat/ui/canvas-followups-8 branch September 15, 2024 00:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend PRs that change frontend files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants