-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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: SVG export in dark mode with embedded bitmap image #4285
fix: SVG export in dark mode with embedded bitmap image #4285
Conversation
This reverts commit 8407268.
bitmap images embedded in SVG are inverted when exporting in dark mode.
to avoid impacting package.json of main project
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/excalidraw/excalidraw/2QuLg67GkPctXhM5SX9TVU3RSnq7 |
Nice catch! It should go into: excalidraw/src/renderer/renderElement.ts Lines 840 to 877 in 620b662
Also, let's use this filter instead (gives better results — at least for canvas double invert, not sure about SVG): excalidraw/src/renderer/renderElement.ts Lines 125 to 129 in 620b662
|
Why a separate declaration. Why not use THEME_FILTER and change the filter here instead?
I am using THEME_FILTER because it needs to mirror this: excalidraw/src/scene/export.ts Line 126 in 620b662
|
Modifying renderElements led to a cleaner solution. Also, I don't need to hardcode filter, I simply use the filter on svgRoot, since that is the one I need to revert. |
Inverting something by 93% and then inverting it again by 93% doesn't give you the original color. That's why I'm using a different filter to more approximate the original colors, though it's not perfect (I also haven't done any exact math and it's not clear to me whether we could come up with a filter in one step to invert it precisely, since we can only invert by up to Here's the examples, in order: 1) the same filter 2) the modified filter 3) ground truth You can see that both the dark-mode images are less saturated, but when using the same filter (1) it's way less saturated than (2). |
still, at least they are not inverted. Excalidraw is not photoshop. Yes, it is great if pictures look saturated, but if you are after perfect colors, work with photoshop, if you want to sketch, the current solution is fit for purpose. So why not change |
Inverting white by 100% gives you pure black which isn't a good default for dark mode. IIRC the
I'm not sure what you're arguing for here. You can see above that using the modified filter gives you outputs closer to ground truth, so why not use that? Is the only argument against this a code consistency? |
Got you, so what you are asking is that instead of we do: ? |
I've refactored the code and instead of detecting dark mode from |
Solves this problem:
2021-11-20.11-27-11.mp4
After fix:
2021-11-20.11-33-06.mp4