replicate / scribble-diffusion

Turn your rough sketch into a refined image using AI
https://scribblediffusion.com
MIT License
2.93k stars 589 forks source link

Use a new canvas implementation #31

Closed zeke closed 1 year ago

zeke commented 1 year ago

The existing react-sketch-canvas package that's currently used has a number of issues:

There are probably a lot of alternative npm packages out there that do the same thing, but better. Here are some that might be useful:

zeke commented 1 year ago

I would love help from the community on this one!

scsmash3r commented 1 year ago

It seems that this is the problem with a mask. I'm not familiar with react, nor with that one lib, but digging briefly through the code, it seems that the mask is used with eraser function.

Since you don't have an erasing element on your canvas, but "Undo" button instead, you could remove mask attribute from #react-sketch-canvas element to show whole canvas without that mask. For me it solves the problem on Firefox.

https://user-images.githubusercontent.com/4781532/222332276-d34b3261-5baf-46d4-9da2-c4f49d9f0481.mp4

scsmash3r commented 1 year ago

This Greasemonkey script serves as a workaround on a client's side, but if added serverside, it can temporary solve the problem till the full-fledged fix :P

  // ==UserScript==
  // @name scribblediffusion canvas temp fix
  // @description Removes mask attr from canvas element for proper view in firefox
  // @match https://scribblediffusion.com/
  // @version   1.0.0
  // ==/UserScript==

  window.addEventListener('load', function () {
      var canvas_with_mask = document.querySelector("#react-sketch-canvas__stroke-group-0");
      canvas_with_mask.removeAttribute("mask");
  })
kcoderhtml commented 1 year ago

I can verify that the script @scsmash3r gave fixes the issue.

zeke commented 1 year ago

Nice work! Thanks for your help on this.

https://twitter.com/zeke/status/1631507015863517184