Skip to main content

ascii-moon-phase-python

Prints the current moon phase as ASCII art. Install with pip install ascii-moon-phase and run with python -m ascii_moon_phase.

usage: ascii-moon-phase [-h] [--size SIZE] [--rotate DEGREES] [--date DATE] [--phase PHASE] [--light-char CHAR]
                        [--dark-char CHAR] [--empty-char CHAR] [--show-phase] [--phases] [--future]

Render the lunar phase as filled ASCII art.

options:
  -h, --help         show this help message and exit
  --size SIZE        Height in rows (width is 2*size). Default: 24
  --rotate DEGREES   Clockwise rotation in degrees. At 0 (default), phases move right to left. At 180, phases move
                     left to right.
  --date DATE        Calendar date YYYY-MM-DD (default: today).
  --phase PHASE      Phase fraction in [0.0, 1.0]; 0.0=new, 0.5=full, 1.0=new. Overrides --date.
  --light-char CHAR  Character for illuminated area (default: '@').
  --dark-char CHAR   Character for dark area (default: '.').
  --empty-char CHAR  Character outside the disc (default: space).
  --show-phase       Print the numeric phase after the art.
  --phases           Animate the full cycle of lunar phases.
  --future           Animate upcoming lunar phases.

You can also call these functions from Python:

>>> import ascii_moon_phase as amp
>>> print(amp.render_moon())
                 ...@@@@@@@@@@@
            .....@@@@@@@@@@@@@@@@@@@
         .......@@@@@@@@@@@@@@@@@@@@@@@
       .......@@@@@@@@@@@@@@@@@@@@@@@@@@@
     ........@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    ........@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
   .........@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  .........@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 ..........@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 ..........@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
..........@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
..........@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
..........@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
..........@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 ..........@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 ..........@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  .........@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
   .........@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    ........@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
     ........@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
       .......@@@@@@@@@@@@@@@@@@@@@@@@@@@
         .......@@@@@@@@@@@@@@@@@@@@@@@
            .....@@@@@@@@@@@@@@@@@@@
                 ...@@@@@@@@@@@

The parameters of render_moon() are:

def render_moon(
    size: int = 24,
    rotation: float = 0.0,
    phase_date: date | None = None,
    light_char: str = "@",
    dark_char: str = ".",
    empty_char: str = " ",
    phase: float | None = None,
) -> str:

You can also call animate_phases() to play a smooth animation of the moon, or call animate_future() to show the phase of each day progressing into the future.

The Rust version is at https://github.com/asweigart/ascii-moon-phase-rust

Metadata

Release files for ascii-moon-phase 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ascii-moon-phase 0.4.0
File Size Uploaded Provenance
ascii_moon_phase-0.4.0.tar.gz 6.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ascii-moon-phase 0.4.0
File Interpreter ABI Platform
ascii_moon_phase-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 12.3 kB

Release files / ascii_moon_phase-0.4.0.tar.gz

Download URL ascii_moon_phase-0.4.0.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
ea6f0562e4fdff12c193e34884f124435b353e859df3d057a6d14ebbf504d65b
BLAKE2b-256 checksum
How to use checksums
a6cb14988a196ac7ef74882bb0058357b87068395e1be07546f747bb244aacb7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Release files / ascii_moon_phase-0.4.0-py3-none-any.whl

Download URL ascii_moon_phase-0.4.0-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0ecc9d402c59b56649e797f6d4400a6cf2d467574dae187233abd6cb58eff8cc
BLAKE2b-256 checksum
How to use checksums
e7cfe859eb9b8785fe57f67b5cca6c94cd7b2ebb81b6dccf51d1989492dc052b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Security for ascii-moon-phase 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page