Skip to main content

Matplotlib-based canvas that allows line drawing and coordinate retrieval

Project description

Coordinate Canvas

Interactive canvas that allows you to draw 2D coordinates in a plane and output their corresponding coordinates to a JSON file.

[!NOTE] All instructions in this README assume your Python 3.11.6+ installation is in your PATH and is aliased under python. If this is not the case, you will need to replace python with the alias or path that points to the correct Python executable.

Installation

python -m pip install ccanvas  # Use dash instead of underscore!

Usage

You can display the help message by running the following command:

python -m ccanvas --help  # Use underscore instead of dash!

Once the canvas has been opened, you will be able to click on any part of it and add a new coordinate. Lines can be switched using the numeric pad on the keyboard, as explained on the header of the window.

Once you have added all the desired coordinates, just press the "Escape" or "Q" keys or close the window. A JSON file will be generated containing all the coordinates you added. This is how the JSON structure looks like:

{
    "line_1": {
        "x": [
            3.064516129032258,
            5.510752688172044,
            10.45698924731183,
            14.045698924731184,
            ...
        ],
        "y": [
            8.837828837828837,
            13.18015318015318,
            13.126873126873129,
            8.03862803862804,
            ...
        ]
    },
    "line_2": {
        ...
    },
    ...
}

Data retrieval

JSON data can easily be retrieved with a few lines of code.

import json

# Assuming the script is located in the same directory where the program is
#   being executed (if not, modify the path below):
with open("coordinates.json", mode="r", encoding="utf-8") as fp:
    data = json.load(fp)  # Loads all data in a dictionary.

# Ways to retrieve data:
line_1 = data["line_1"]
line_1_x = data["line_1"]["x"]
line_1_y = data["line_1"]["y"]
line_1_xy = [(x, y) for x, y in zip(data["line_1"].values())]  # Recommended!

Contributing

If you are planning on contributing to the repository, take a look at the contribution guidelines.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ccanvas-1.5.1.tar.gz (44.2 kB view details)

Uploaded Source

Built Distribution

ccanvas-1.5.1-py3-none-any.whl (33.1 kB view details)

Uploaded Python 3

File details

Details for the file ccanvas-1.5.1.tar.gz.

File metadata

  • Download URL: ccanvas-1.5.1.tar.gz
  • Upload date:
  • Size: 44.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for ccanvas-1.5.1.tar.gz
Algorithm Hash digest
SHA256 e306db02703ab3ed6b96cf4c72d122149c95feb9fb957e9fbbe57b3d09d372e8
MD5 746cf415a09e5ff8932a629350fe9487
BLAKE2b-256 5f06d7a04291744ff89cd8731c02e168160e4a618abaa7fe39bd75d7b1e51100

See more details on using hashes here.

File details

Details for the file ccanvas-1.5.1-py3-none-any.whl.

File metadata

  • Download URL: ccanvas-1.5.1-py3-none-any.whl
  • Upload date:
  • Size: 33.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for ccanvas-1.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c3349d981e562b9abb43aa117e9de1444273ad224f201eac9759712eb500cb6a
MD5 a28584a2915cfe70942d75209868b4c1
BLAKE2b-256 3a4f925225ed046ba58b3691934c87bfaeb0eece28b068bf669cb499ece28904

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page