Skip to main content

A geometry engine for Python with text-based syntax and PNG export

Project description

Shapix

A geometry engine for Python with text-based syntax and PNG export capabilities.

Features

  • Simple text-based syntax for defining geometric shapes
  • Multiple shape types: Points, Lines, Circles, Triangles, Angles
  • PNG export with automatic scaling and positioning
  • Flexible rendering with customizable colors, labels, and styling
  • Mathematical operations like area, perimeter, angle calculations
  • Clean object-oriented API for programmatic use

Installation

pip install shapix

Quick Start

Using Text Syntax

from shapix.syntax import export_geometry_syntax

# Define geometry using simple text syntax
geometry = '''
POINT O 0 0 "O" show_label=true label_position=bottom_right
POINT A 0 100 "A" show_label=true label_position=top
POINT B -87 50 "B" show_label=true label_position=top_left
CIRCLE O 100 color=blue
TRIANGLE A B O color=green
ANGLE B O A color=red arc=true show_measure=true
'''

# Export to PNG
export_geometry_syntax(geometry, "my_diagram.png", width=800, height=600)

Using Python API

from shapix.core import Point
from shapix.shapes import Circle, Triangle
from shapix.rendering import ShapeRenderer

# Create shapes programmatically  
center = Point(0, 0, "O")
circle = Circle(center, radius=100)
circle.color = "blue"

vertex_a = Point(0, 100, "A")
vertex_b = Point(-87, 50, "B") 
triangle = Triangle(vertex_a, vertex_b, center)
triangle.color = "green"

# Render to canvas or export
# ... (rendering code)

Syntax Reference

Points

POINT name x y "label" show_label=true label_position=top_right

Circles

CIRCLE center_point radius color=blue show_center=true

Lines

LINE start_point end_point color=red show_endpoints=true

Triangles

TRIANGLE point1 point2 point3 color=green show_vertices=true

Angles

ANGLE point1 vertex point2 color=red arc=true show_measure=true

Shape Properties

All shapes support common properties:

  • color - Outline color
  • fill_color - Fill color
  • line_width - Line thickness
  • font_size - Label font size
  • text_color - Label text color
  • visible - Show/hide shape
  • layer - Drawing order

Label Positions

Points and labels can be positioned using:

  • top_left, top, top_right
  • center_left, center, center_right
  • bottom_left, bottom, bottom_right
  • left, right

Requirements

  • Python 3.8+
  • Pillow (for PNG export)
  • tkinter (usually included with Python)

License

MIT License

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

shapix-0.1.0.tar.gz (21.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

shapix-0.1.0-py3-none-any.whl (25.2 kB view details)

Uploaded Python 3

File details

Details for the file shapix-0.1.0.tar.gz.

File metadata

  • Download URL: shapix-0.1.0.tar.gz
  • Upload date:
  • Size: 21.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for shapix-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e2adf77ee112ac8a5cc4a7f84b2e41c0bd93ef8045a0f25f1fc2a0e2f1e80335
MD5 353ccf12ee36028523b9c6620b0ab212
BLAKE2b-256 edc37b7a0a2e9c52bcd665273d932db9a24f94cc36dd35bf61b075edc56d4ea1

See more details on using hashes here.

File details

Details for the file shapix-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: shapix-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 25.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for shapix-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 60bd7eea70fcb90aba7b7694def08e233e2c7596cac87f6c9b3c45f6dcf5cb77
MD5 94739e9554b9a10ac0c53f06d027cf82
BLAKE2b-256 adaaa0db6650c76dc1e9b8b3026178c0b66564f63d816cac1aa2bcfed2621046

See more details on using hashes here.

Supported by

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