Adding an option for use Asymptote to build svg graphics#1145
Adding an option for use Asymptote to build svg graphics#1145
Conversation
… possible fail in os.getlogin()
|
If we agree to add this, it would be useful to set |
mathics/builtin/graphics.py
Outdated
| return elements, calc_dimensions | ||
|
|
||
| def boxes_to_tex(self, leaves, **options): | ||
| def boxes_to_tex(self, leaves, forxml=False, **options): |
There was a problem hiding this comment.
Adding a parameter like this feels really hacky.
The front end should be involved here. The backend merely needs to provide the underlying building blocks.
There was a problem hiding this comment.
Adding a parameter like this feels really hacky.
Agree. Maybe I should hide it inside **options
The front end should be involved here. The backend merely needs to provide the underlying building blocks.
OK, but for it, I would need to merge #1140 first...
There was a problem hiding this comment.
The idea of these modifications is to have a working graphics engine without changing the current core. Most of the code is there, and if the control variable is not set (or set to false), we get the previous (buggy) behavior.
On the other hand, this does not clash against #1140, this is why I put this in a separated PR.
There was a problem hiding this comment.
Adding a parameter like this feels really hacky.
The front end should be involved here. The backend merely needs to provide the underlying building blocks.
Regarding this, I putforxmlas an optional parameter.
rocky
left a comment
There was a problem hiding this comment.
I believe there is code in the tree drawing routines of pymathics-graph that suggest how to scale the text font size based the distance between nodes which here would be applied to axis labels.
| def is_zero(self) -> bool: | ||
| return self.numerator().is_zero and not self.denominator().is_zero() | ||
| return self.numerator().is_zero and not(self.denominator().is_zero) | ||
|
|
There was a problem hiding this comment.
Should this be in a separate PR. It fixes a current bug and is not specific to asymptote, right?
There was a problem hiding this comment.
I put this because I got CI errors due to PossibleZeroQ. I removed this change from this PR. Please look at #1164.
Given the above, I am guessing there is some coordination that needs to go on with Mathics-Django. In other words this gets created, but Mathics-Django doesn't know that it has to do something special go get this image pulled in, right? |
|
BTW although this is really good stuff, I am delighted we didn't delay the last release further to try to get this in. |
I tried with the master branch of mathics-django and it works for me, with this branch of Mathics. I have created a PR in mathics-django that sets the variable to True. @rocky, please have a look when you have time. |
|
I spent some time tracking down what's up. If I use firefox I see the information. But if I use google chrome I don't. In the chrome cases I do see: getting sent back. |
|
It also doesn't work on the opera browser |
|
Updates:
|
@mmatera Ok. So is this branch obsolete? Or in need of code removal/update? |
|
I close this because all the code is inside pymathics-asy. |

This PR partially fix #1078.
The idea is to be able of producing SVG graphics that do not contain MathML code inside. If Asymptote is available in the system, and the symbol
Settings`UseAsyForGraphics2Dis set to True, whenGraphicsBox.boxes_to_xmlis called, instead of using the internal code for building svg images,GraphicsBox.boxes_to_texis called to produce a set of asy instructions. These instructions are saved in a temporary file, which is sent to theasyinterpreter in order to produce an svg file. Finally,GraphicsBox.boxes_to_xmlreturns and<img>tag, with the contain of this file, codified as a b64 string assrc.This allows also us to show expressions with nested graphics and equations.