galgebra icon indicating copy to clipboard operation
galgebra copied to clipboard

Change svg background color for dark mode

Open utensil opened this issue 4 years ago • 12 comments

utensil avatar May 28 '20 01:05 utensil

Codecov Report

Merging #415 into master will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #415   +/-   ##
=======================================
  Coverage   77.56%   77.56%           
=======================================
  Files          16       16           
  Lines        4217     4217           
=======================================
  Hits         3271     3271           
  Misses        946      946           

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 7f57a09...035add5. Read the comment docs.

codecov[bot] avatar May 28 '20 01:05 codecov[bot]

Somehow this doesn't actually work yet, my guess is that the styles in tag svg has no effect or no precedence. PR it anyway to mark the issue:

In README:

image

In https://github.com/pygae/galgebra/blob/master/doc/module-components.rst#latex-printing :

image

GitHub
Symbolic Geometric Algebra/Calculus package for SymPy :crystal_ball: - pygae/galgebra

utensil avatar May 28 '20 01:05 utensil

Is this a problem just for the readme, or the Sphinx docs too?

eric-wieser avatar May 28 '20 05:05 eric-wieser

Currently only for .md and .rst in Github Dark theme .

utensil avatar May 28 '20 05:05 utensil

https://github.com/StylishThemes/GitHub-Dark

GitHub
:octocat: Dark GitHub style. Contribute to StylishThemes/GitHub-Dark development by creating an account on GitHub.

utensil avatar May 28 '20 05:05 utensil

Somehow this doesn't actually work yet, my guess is that the styles in tag svg has no effect or no precedence.

What I usually do in these cases is create a rectangle for the background, with the same dimensions as the svg document/viewport. For example, for Dop.svg, that would be:

 </defs>
+<rect width="400" height="375" fill="#fcfcfc"/>
 <g id="surface1">

May I ask why use rgb(252,252,252) / #fcfcfc instead of plain white, though? That will make these slightly off in a white background.

Also, note that the contents of the SVG files are immediately adjacent to its margins, so a white fill would still not look good in a dark background. You'd need some sort of margin, e.g.:

 <?xml version="1.0" encoding="UTF-8"?>
-<svg ... width="400pt" height="375pt" viewBox="0 0 400 375" version="1.1">
+<svg ... width="400pt" height="375pt" viewBox="-10 10 420 395" version="1.1">
 <defs>
 ...
 </defs>
+<rect x="-10" y="-10" width="420" height="395" fill="#fcfcfc"/>
 <g id="surface1">
 ...
 </g>
 </svg>

waldyrious avatar May 28 '20 09:05 waldyrious

May I ask why use rgb(252,252,252) / #fcfcfc instead of plain white, though? That will make these slightly off in a white background.

Using rgb(252,252,252) / #fcfcfc is to match the background color of http://galgebra.readthedocs.io/.

utensil avatar May 28 '20 09:05 utensil

What I usually do in these cases is create a rectangle for the background, with the same dimensions as the svg document/viewport. For example, for Dop.svg, that would be:

 </defs>
+<rect width="400" height="375" fill="#fcfcfc"/>
 <g id="surface1">

Thanks for the suggestion. Why I'm hesitating is that this method is too manual, although not much of trouble.

utensil avatar May 28 '20 09:05 utensil

Could alternatively fix this with https://github.com/StylishThemes/GitHub-Dark/issues/1060, which is what makes this work:

e^{i /pi} = -1

Edit: #418 is a failed attempt at this

eric-wieser avatar May 28 '20 09:05 eric-wieser

![](https://render.githubusercontent.com/render/math?math=%5CHuge%20e%5E%7Bi%5Cpi%7D%20%3D%20-1) gives:

which looks like this:

image

utensil avatar May 28 '20 09:05 utensil

Sounds like a bug you should report back to Github-Dark.

eric-wieser avatar May 28 '20 09:05 eric-wieser

Sounds like a bug you should report back to Github-Dark.

Indeed, will do that instead.

utensil avatar Jun 01 '20 01:06 utensil

Related post: https://driesvints.com/blog/investigating-dark-mode-for-svgs-in-github-readmes

Related SO answer: https://stackoverflow.com/a/70200610/200764

Latest official solution: https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#specifying-the-theme-an-image-is-shown-to

utensil avatar Mar 30 '24 10:03 utensil

Superseded by #503

utensil avatar Mar 30 '24 11:03 utensil