A package for 2D geometry in Python
Project description
PyGeometry
Python package to create 2D geometries.
Getting Started
Installation
pip install --index-url https://test.pypi.org/simple/ --no-deps pygeometry-pkg-naysan -U
Usage Examples
Cartesian coordinate axes + points
from pygeom import Axes, Point
# Create the cartesian axis
axes = Axes(xlim=(-1,8), ylim=(-1,18), figsize=(9,7))
# Create two points
p1 = Point(2, 5, color='#ffa500')
p2 = Point(7, 17, color='#0000ff')
axes.addMany([p1, p2])
axes.draw()
Line Demo
from pygeom import Axes, Point, Line
# Create the cartesian axis
axes = Axes(xlim=(-1,7), ylim=(-1,7), figsize=(7,6))
# Points
p1 = Point(1, 1, color='red')
p2 = Point(5, 4, color='green')
l = Line(p1=p1, p2=p2)
axes.addMany([p1, p2, l])
axes.draw()
Triangle Demo
from pygeom import Axes, Point, Triangle
%matplotlib inline # For Jupyter Notebook
# Create the cartesian axis
axes = Axes(xlim=(-1,10), ylim=(-1,10), figsize=(12,10))
# Points
p1 = Point(1, 1, color='grey')
p2 = Point(5, 5, color='grey')
p3 = Point(8, 5, color='grey')
tr = Triangle(p1, p2, p3, alpha=0.5)
axes.addMany([p1, p2, p3])
axes.add(tr)
axes.draw()
Rectangle Demo
from pygeom import Axes, Point, Rectangle
%matplotlib inline
# Create the cartesian axis
axes = Axes(xlim=(-1,7), ylim=(-1,7), figsize=(12,10))
# Points
bottomLeft = Point(1, 1, color='red')
topRight = Point(5, 4, color='green')
shape = Rectangle(bottomLeft, topRight, alpha=0.5)
axes.addMany([bottomLeft, topRight])
axes.add(shape)
axes.draw()
Polygon Demo
from pygeom import Axes, Point, Polygon
%matplotlib inline
# Create the cartesian axis
axes = Axes(xlim=(-1,10), ylim=(-1,10), figsize=(12,10))
# Points
p1 = Point(1, 1, color='red')
p2 = Point(1, 2, color='green')
p3 = Point(4, 7, color='red')
p4 = Point(9, 1, color='green')
shape = Polygon([p1, p2, p3, p4], alpha=0.5)
axes.addMany([p1, p2, p3, p4])
axes.add(shape)
axes.draw()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyGeom2D-0.1.1.tar.gz
(7.7 kB
view hashes)
Built Distribution
pyGeom2D-0.1.1-py3-none-any.whl
(10.9 kB
view hashes)