-
-
Notifications
You must be signed in to change notification settings - Fork 205
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
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mathics/builtin/graphics.py
Outdated
@@ -3142,7 +3142,7 @@ def get_range(min, max): | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's wait until #1140 clears then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 putforxml
as an optional parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
mathics/core/expression.py
Outdated
@@ -2137,7 +2137,7 @@ def __neg__(self) -> 'Rational': | |||
|
|||
@property | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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`UseAsyForGraphics2D
is set to True, whenGraphicsBox.boxes_to_xml
is called, instead of using the internal code for building svg images,GraphicsBox.boxes_to_tex
is called to produce a set of asy instructions. These instructions are saved in a temporary file, which is sent to theasy
interpreter in order to produce an svg file. Finally,GraphicsBox.boxes_to_xml
returns 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.