Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 32 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
|CI status| |Pypi Installs| |Latest Version| |Supported Python Versions|
|CI status| |PyPI Installs| |Latest Version| |Supported Python Versions|

|Packaging status|

Expand All @@ -18,7 +18,7 @@ Features
- limited ESC keyboard input; for example *esc* ``p`` *esc* is π
* Syntax highlighting using `mathics-pygments <https://pypi.org/project/mathics-pygments/>`_ which includes dynamically created variables and functions.
* Automatic detection of light or dark `terminal background color <https://pypi.org/project/term-background/>`_.
* Optional Graphics rendering via `matplotlib <https://matplotlib.org/>`_ for 2D graphics, and `Asymptote <https://asymptote.sourceforge.io>`_ for 3D graphcs.
* Optional Graphics rendering via `matplotlib <https://matplotlib.org/>`_ for 2D graphics, and `Asymptote <https://asymptote.sourceforge.io>`_ for 3D and 2D graphics.
* Entering and displaying Unicode symbols such as used for Pi or Rule arrows
* Provision for running in non-interactive batch mode which an be used inside POSIX shells

Expand Down Expand Up @@ -94,6 +94,35 @@ Feeding this into ``mathicsscript``:
For a full list of options, type ``mathicsscript --help``.


Asymptote key bindings
----------------------

In asymptote graphs keyboard bindings are (copied from the asymptote
doc under `8.29 three
<https://asymptote.sourceforge.io/doc/three.html#index-keyboard-bindings_003a>`_::

h: home
f: toggle fitscreen
x: spin about the X axis
y: spin about the Y axis
z: spin about the Z axis
s: stop spinning
m: rendering mode (solid/patch/mesh)
e: export
c: show camera parameters
p: play animation
r: reverse animation
: step animation
+: expand
=: expand
>: expand
-: shrink
_: shrink
<: shrink
q: exit
Ctrl-q: exit


Why not IPython via Jupyter?
----------------------------

Expand All @@ -114,7 +143,7 @@ the core Mathic3 package.
.. |screenshot| image:: https://mathics.org/images/mathicsscript1.gif
.. |Latest Version| image:: https://badge.fury.io/py/mathicsscript.svg
:target: https://badge.fury.io/py/mathicsscript
.. |Pypi Installs| image:: https://pepy.tech/badge/mathicsscript
.. |PyPI Installs| image:: https://pepy.tech/badge/mathicsscript
.. |Supported Python Versions| image:: https://img.shields.io/pypi/pyversions/mathicsscript.svg
.. |CI status| image:: https://github.com/Mathics3/mathicsscript/workflows/mathicsscript%20(ubuntu)/badge.svg
:target: https://github.com/Mathics3/mathicsscript/actions
Expand Down
17 changes: 11 additions & 6 deletions mathicsscript/asymptote.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
from tempfile import NamedTemporaryFile
from typing import Optional

asy_program = os.environ.get("ASY_PROG", "asy")
# An aysmptote string to
INTEACTIVE_PREAMBLE = """
// Generated by Mathics3 mathicsscript.
"""

ASY_PROGRAM = os.environ.get("ASY_PROG", "asy")

# Add asymptote directory to AYMPTOTE_DIR
asymptote_dir = os.environ.get("ASYMPTOTE_DIR", "")
Expand All @@ -23,7 +28,7 @@
asymptote_version: Optional[str] = None
try:
result = run(
[asy_program, "--version"],
[ASY_PROGRAM, "--version"],
timeout=0.5,
stdout=PIPE,
stderr=PIPE,
Expand All @@ -46,10 +51,10 @@ def get_srcdir():
asy_config = os.path.join(mydir, "config.asy")


class Asy(object):
class Asy:
def __init__(self, show_help=True):
self.session = Popen(
[asy_program, f"-config={asy_config}", "-quiet", "-inpipe=0", "-outpipe=2"],
[ASY_PROGRAM, f"-config={asy_config}", "-quiet", "-inpipe=0", "-outpipe=2"],
stdin=PIPE,
)
if show_help:
Expand Down Expand Up @@ -103,8 +108,8 @@ def write_asy_and_view(asy_string: str):
with NamedTemporaryFile(
mode="w", prefix="Mathics3-Graph-", suffix=".asy", delete=False
) as asy_fp:
asy_fp.write(asy_string + "\n")
subprocess.run(args=[asy_program, "-View", asy_fp.name])
asy_fp.write(INTEACTIVE_PREAMBLE + asy_string + "\n")
subprocess.run(args=[ASY_PROGRAM, "-View", asy_fp.name])


if __name__ == "__main__":
Expand Down
Loading