Enter-tainer / typst-preview

[DEPRECATED] Use tinymist instead
https://Enter-tainer.github.io/typst-preview/
MIT License
452 stars 21 forks source link

feat(invert-colors): add normal-image option #301

Open SetsuikiHyoryu opened 2 weeks ago

SetsuikiHyoryu commented 2 weeks ago

I noticed that https://github.com/Enter-tainer/typst-preview/pull/230 added a color inversion mode. I'm not sure why the developer decided to default the image colors to invert as well. I understand he allowed hovering to return the colors to normal, but this strains my eyes when viewing in the default state.

I didn't want to disrupt his intention, so I simply added an option to allow users the choice to display images in normal colors by default.

Enter-tainer commented 2 weeks ago

cc @Myriad-Dreamin how about changing the default behavior?

Enter-tainer commented 2 weeks ago

i remember the intention is that if we have big white images, the page is still pretty 'light'. so we inverted it by default and we switch it back to normal when hovering it.

Enter-tainer commented 2 weeks ago

i think both of this may make sense but having too many config options can be confusing, user may struggle to understand the behavior of them

SetsuikiHyoryu commented 2 weeks ago

i remember the intention is that if we have big white images, the page is still pretty 'light'. so we inverted it by default and we switch it back to normal when hovering it.

Inversion also means that large dark areas will become bright. If glaring situations cannot be avoided, I think it would be more user-friendly to adhere to intuitive visual effects.

Moreover, if a user chooses dark mode here, I think they are unlikely to create images with large bright areas.

Enter-tainer commented 2 weeks ago

I wonder if css can do this: invert the image conditionally based on its original state. If it's light, it should be inverted, otherwise it's kept as is. And hovering always removes the filter and shows the original image

Myriad-Dreamin commented 2 weeks ago

Inversion also means that large dark areas will become bright. If glaring situations cannot be avoided, I think it would be more user-friendly to adhere to intuitive visual effects.

Whether it inverts colors of images by default or not, we will get some bad cases. If we don't invert them, the "dark" images having transparent background will be invisible in preview. If not, the dark-style images will get turned to light-style images. The current behavior should take more good cases. The smarter behavior imo is letting preview identify dark-style images and process them.

add normal-image option

It is okay to keep colors of images with some option, but it is not great to add an enumerated value along with always, auto, and never. The correct design might be:

{
  "invertColors": "always", // or
  "invertColors": {
    "all": "auto",
    "image": "never",
  }, // or
  "invertColors": {
    "always" : ["all"],
    "never": ["image"],
  },
}
SetsuikiHyoryu commented 2 weeks ago

Inversion also means that large dark areas will become bright. If glaring situations cannot be avoided, I think it would be more user-friendly to adhere to intuitive visual effects.

Whether it inverts colors of images by default or not, we will get some bad cases. If we don't invert them, the "dark" images having transparent background will be invisible in preview. If not, the dark-style images will get turned to light-style images. The current behavior should take more good cases. The smarter behavior imo is letting preview identify dark-style images and process them.

add normal-image option

It is okay to keep colors of images with some option, but it is not great to add an enumerated value along with always, auto, and never. The correct design might be:

{
  "invertColors": "always", // or
  "invertColors": {
    "all": "auto",
    "image": "never",
  }, // or
  "invertColors": {
    "always" : ["all"],
    "never": ["image"],
  },
}

Ok, I'll change it.

SetsuikiHyoryu commented 2 weeks ago

@Enter-tainer @Myriad-Dreamin I have completed the modifications mentioned above. Sorry, I'm not sure how to change the package.json document in the new format. Could you please help by writing it for me?