# Gemmini
[![Pypi](https://img.shields.io/badge/pypi-1.0.1-blue.svg)](https://pypi.org/project/gemmini/)
[![Python](https://img.shields.io/badge/python-%3E%3D%203.7-green.svg)](https://www.python.org/downloads/)
[![pytest](https://github.com/byanko55/gemmini/actions/workflows/pytest.yml/badge.svg)](https://github.com/byanko55/gemmini/actions/workflows/pytest.yml)
[![](https://img.shields.io/badge/License-BSD%203--Clause-orange.svg)](https://opensource.org/licenses/MIT)
> Python package for visualizing and manipulating diverse geometric shapes.
![Demo 1](https://i.ibb.co/9s4twNn/all-with-interior.webp)
![Demo 2](https://i.ibb.co/0QSnDdZ/all-with-exterior.webp)
`Gemmini` provides **70+ geometry classes** including common polygons, curves, and symbols. Built with `numpy` and `matplotlib` packages, it supports easy manipulation and illustration of geometry, while plenty of useful functions for mathematical analysis and 2D/3D transformation are also available.
## Geometries supported by Gemmini
### Pointset
* Point
* Pointcloud
* Grid
### Line
* Line
* Segment
### Polygon
* RegularPolygon
* IsoscelesTriangle
* RightTriangle
* Parallelogram
* Rhombus
* Trapezoid
* RightTrapezoid
* Rectangle
* Kite
* ConcaveKite
* ConcaveStar
### Curve
* Circle
* Arc
* Ellipse
* Spiral
* HyperbolicSpiral
* ParabolicSpiral
* LituusSpiral
* LogarithmicSpiral
* BoundedSpiral
* Cycloid
* Epicycloid
* Hypocycloid
* CurvedPolygon
* Lissajous
* Folium
* Bifolium
### Other shapes
* CircularSector
* CircularSegment
* Wave
* Helix
* Parabola
* SymmetricSpiral
* Star
* Heart
* ButterFly
* CottonCandy
* Boomerang
* Stellate
* Shuriken
* Flower_A
* Flower_B
* Flower_C
* Flower_D
* Flower_E
* Flower_F
* Clover
* FattyStar
* Moon
* Yinyang
* Polygontile
* Gear
* SnippedRect
* RoundedRect
* Plaque
* Ring
* BlockArc
* Cross_A
* Cross_B
* Cross_C
* SunCross
* CelticCross
* BasqueCross
* Lshape
* HalfFrame
* Arrow
* DoubleArrow
* ArrowPentagon
* ArrowChevron
* Teardrop
* Nosign
## Transformation
```Python
import gemmini as gm
f = gm.SunCross(s=9)
gm.plot((f), fill=True)
f.shatter((2, 4), rate=2)
gm.plot((f), fill=True)
gm.plot((f), show_area=True)
```
![Demo 3](https://i.ibb.co/2P1vcvn/example1.webp)
### List of transformations
* **Resizing** - `scale`, `scaleX`, `scaleY`
* **Position Shift** - `translate`, `translateX`, `translateY`
* **Rotation** - `rotate`, `rotateX`, `rotateY`, `rotateZ`, `rotate3D`
* **Symmetric Shift** - `flip`, `flipX`, `flipY`, `flipXY`, `flipDiagonal`
* **Distortion** - `skew`, `skewX`, `skewY`, `distort`, `focus`, `shatter`
* **Others** - `dot`
## Figure Visualization
Create a `Canvas`, on which your nice geometries will be drawn. Make a choice of color theme (default: `light`), canvas size, grid opacity, etc. You can plot either a single geometric object or multiple shapes altogether.
```Python
import gemmini as gm
import numpy as np
canva = gm.Canvas()
cluster_small = gm.Pointcloud2D(s=0.05, num_dot=10)
cluster_medium = gm.Pointcloud2D(s=0.1, num_dot=20)
cluster_large = gm.Pointcloud2D(s=0.2, num_dot=50)
canva.add((cluster_small, cluster_medium, cluster_large), show_center=True)
canva.plot()
```
![Demo 4](https://i.ibb.co/Vtzhhtt/output5.webp)
### Display Options
* **fill** - fill in the interior of the geometry
* **show_edges** - draw path enclosing the given geometry
* **show_radius** - display a radius vector and its length
* **show_size** - display a height/width of the geometry
* **show_center** - display (x, y) coordinates of the centroid
* **show_area** - display the area of the geometry
* **show_class** - display the class name ot the geometry
```Python
import gemmini as gm
canva = gm.Canvas(theme='horizon')
original = gm.IsoscelesTriangle(h=4, w=6)
figs = []
for i in range(6):
f = original.copy()
f.translate(8*(i%3), 8*(i//3))
figs.append(f)
canva.add(figs[0], fill=True)
canva.add(figs[1], show_edges=True)
canva.add(figs[2], show_center=True)
canva.add(figs[3], show_radius=True)
canva.add(figs[4], show_size=True)
canva.add(figs[5], show_area=True)
canva.plot()
```
![Demo 5](https://i.ibb.co/MVrFFdz/example3.webp)
## Requirements
* **Python** >= 3.7
* **numpy** >= 1.21
* **scipy** >= 1.7
* **matplotlib** >= 3.3
## Work with Shapely
We added the simple way to convert geometry to a `shapely` object.
```Python
import gemmini as gm
from shapely import geometry
import matplotlib.pyplot as plt
f = gm.Polygontile(s=4, v=5)
poly = geometry.Polygon(*f.coordSet())
print(poly.wkt)
```
> POLYGON ((0.8980559531591708 1.2360679774997896, 0.9597258534760096 1.4258684144441638, ... ))
```Python
from shapely.plotting import plot_polygon
plot_polygon(poly)
```
![Shapely](https://i.ibb.co/LPk95yY/output7.webp)
## Tutorials
The below page links contain several useful tutorials running on Ipython:
* **Plot a Point/Pointcloud** - [See here](https://github.com/byanko55/gemmini/blob/master/tutorials/test_point.ipynb)
* **Draw a Infinite/finite Line** - [See here](https://github.com/byanko55/gemmini/blob/master/tutorials/test_line.ipynb)
* **Draw various Geometries** - [Polygons](https://github.com/byanko55/gemmini/blob/master/tutorials/test_polygon.ipynb), [Polar Curves](https://github.com/byanko55/gemmini/blob/master/tutorials/test_polar.ipynb), [Other Symbols & Shapes](https://github.com/byanko55/gemmini/blob/master/tutorials/test_shape.ipynb)
* **Apply Transformation to Geometry** - [See here](https://github.com/byanko55/gemmini/blob/master/tutorials/test_transform.ipynb)
* **Plot Geometry on Python Interactive Window** - [See here](https://github.com/byanko55/gemmini/blob/master/tutorials/test_canvas.ipynb)
* **Use case with Shapely package** - [See here](https://github.com/byanko55/gemmini/blob/master/tutorials/test_shapely.ipynb)
* **List of geometrical illustrations** - [All you want is here!](https://github.com/byanko55/gemmini/blob/master/tutorials/test_all.ipynb)
## Contribution
If you'd like a new shape, transformation, or other mathematical operations to be included, **feel free to leave a issue on this repo**. We are welcome to any kinds of request and feedbacks!
Raw data
{
"_id": null,
"home_page": "https://github.com/byanko55/gemmini",
"name": "gemmini",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "geometry,drawing 2D/3D graphic",
"author": "Yankos",
"author_email": "byanko55@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/6a/a9/bf8d39bf1b899ace6ec76347a709e3dbac580406876a4a120f8d26d3dbf4/gemmini-1.0.2.tar.gz",
"platform": null,
"description": "# Gemmini\n\n[![Pypi](https://img.shields.io/badge/pypi-1.0.1-blue.svg)](https://pypi.org/project/gemmini/)\n[![Python](https://img.shields.io/badge/python-%3E%3D%203.7-green.svg)](https://www.python.org/downloads/)\n[![pytest](https://github.com/byanko55/gemmini/actions/workflows/pytest.yml/badge.svg)](https://github.com/byanko55/gemmini/actions/workflows/pytest.yml)\n[![](https://img.shields.io/badge/License-BSD%203--Clause-orange.svg)](https://opensource.org/licenses/MIT)\n\n\n> Python package for visualizing and manipulating diverse geometric shapes.\n\n![Demo 1](https://i.ibb.co/9s4twNn/all-with-interior.webp)\n![Demo 2](https://i.ibb.co/0QSnDdZ/all-with-exterior.webp)\n\n\n`Gemmini` provides **70+ geometry classes** including common polygons, curves, and symbols. Built with `numpy` and `matplotlib` packages, it supports easy manipulation and illustration of geometry, while plenty of useful functions for mathematical analysis and 2D/3D transformation are also available.\n\n## Geometries supported by Gemmini\n\n### Pointset\n* Point\n* Pointcloud\n* Grid\n\n### Line\n* Line\n* Segment\n\n### Polygon\n* RegularPolygon\n* IsoscelesTriangle\n* RightTriangle\n* Parallelogram\n* Rhombus\n* Trapezoid\n* RightTrapezoid\n* Rectangle\n* Kite\n* ConcaveKite\n* ConcaveStar\n\n### Curve\n* Circle\n* Arc\n* Ellipse\n* Spiral\n* HyperbolicSpiral\n* ParabolicSpiral\n* LituusSpiral\n* LogarithmicSpiral\n* BoundedSpiral\n* Cycloid\n* Epicycloid\n* Hypocycloid\n* CurvedPolygon\n* Lissajous\n* Folium\n* Bifolium\n\n### Other shapes\n* CircularSector\n* CircularSegment\n* Wave\n* Helix\n* Parabola\n* SymmetricSpiral\n* Star\n* Heart\n* ButterFly\n* CottonCandy\n* Boomerang\n* Stellate\n* Shuriken\n* Flower_A\n* Flower_B\n* Flower_C\n* Flower_D\n* Flower_E\n* Flower_F\n* Clover\n* FattyStar\n* Moon\n* Yinyang\n* Polygontile\n* Gear\n* SnippedRect\n* RoundedRect\n* Plaque\n* Ring\n* BlockArc\n* Cross_A\n* Cross_B\n* Cross_C\n* SunCross\n* CelticCross\n* BasqueCross\n* Lshape\n* HalfFrame\n* Arrow\n* DoubleArrow\n* ArrowPentagon\n* ArrowChevron\n* Teardrop\n* Nosign\n\n## Transformation\n\n```Python\nimport gemmini as gm\n\nf = gm.SunCross(s=9)\ngm.plot((f), fill=True)\n\nf.shatter((2, 4), rate=2)\ngm.plot((f), fill=True)\ngm.plot((f), show_area=True)\n```\n\n![Demo 3](https://i.ibb.co/2P1vcvn/example1.webp)\n\n### List of transformations\n* **Resizing** - `scale`, `scaleX`, `scaleY`\n* **Position Shift** - `translate`, `translateX`, `translateY`\n* **Rotation** - `rotate`, `rotateX`, `rotateY`, `rotateZ`, `rotate3D`\n* **Symmetric Shift** - `flip`, `flipX`, `flipY`, `flipXY`, `flipDiagonal`\n* **Distortion** - `skew`, `skewX`, `skewY`, `distort`, `focus`, `shatter`\n* **Others** - `dot`\n\n## Figure Visualization\n\nCreate a `Canvas`, on which your nice geometries will be drawn. Make a choice of color theme (default: `light`), canvas size, grid opacity, etc. You can plot either a single geometric object or multiple shapes altogether.\n\n```Python\nimport gemmini as gm\nimport numpy as np\n\ncanva = gm.Canvas()\n\ncluster_small = gm.Pointcloud2D(s=0.05, num_dot=10)\ncluster_medium = gm.Pointcloud2D(s=0.1, num_dot=20)\ncluster_large = gm.Pointcloud2D(s=0.2, num_dot=50)\n\ncanva.add((cluster_small, cluster_medium, cluster_large), show_center=True)\ncanva.plot()\n```\n\n![Demo 4](https://i.ibb.co/Vtzhhtt/output5.webp)\n\n### Display Options\n\n* **fill** - fill in the interior of the geometry\n* **show_edges** - draw path enclosing the given geometry\n* **show_radius** - display a radius vector and its length\n* **show_size** - display a height/width of the geometry\n* **show_center** - display (x, y) coordinates of the centroid\n* **show_area** - display the area of the geometry\n* **show_class** - display the class name ot the geometry\n\n```Python\nimport gemmini as gm\n\ncanva = gm.Canvas(theme='horizon')\n\noriginal = gm.IsoscelesTriangle(h=4, w=6)\nfigs = []\n\nfor i in range(6):\n f = original.copy()\n f.translate(8*(i%3), 8*(i//3))\n figs.append(f)\n\ncanva.add(figs[0], fill=True)\ncanva.add(figs[1], show_edges=True)\ncanva.add(figs[2], show_center=True)\ncanva.add(figs[3], show_radius=True)\ncanva.add(figs[4], show_size=True)\ncanva.add(figs[5], show_area=True)\n\ncanva.plot()\n```\n\n![Demo 5](https://i.ibb.co/MVrFFdz/example3.webp)\n\n## Requirements\n\n* **Python** >= 3.7\n* **numpy** >= 1.21\n* **scipy** >= 1.7\n* **matplotlib** >= 3.3\n\n## Work with Shapely\n\nWe added the simple way to convert geometry to a `shapely` object. \n\n```Python\nimport gemmini as gm\n\nfrom shapely import geometry\nimport matplotlib.pyplot as plt\n\nf = gm.Polygontile(s=4, v=5)\npoly = geometry.Polygon(*f.coordSet())\nprint(poly.wkt)\n```\n\n> POLYGON ((0.8980559531591708 1.2360679774997896, 0.9597258534760096 1.4258684144441638, ... ))\n\n```Python\nfrom shapely.plotting import plot_polygon\n\nplot_polygon(poly)\n```\n\n![Shapely](https://i.ibb.co/LPk95yY/output7.webp)\n\n## Tutorials\n\nThe below page links contain several useful tutorials running on Ipython:\n\n* **Plot a Point/Pointcloud** - [See here](https://github.com/byanko55/gemmini/blob/master/tutorials/test_point.ipynb)\n* **Draw a Infinite/finite Line** - [See here](https://github.com/byanko55/gemmini/blob/master/tutorials/test_line.ipynb)\n* **Draw various Geometries** - [Polygons](https://github.com/byanko55/gemmini/blob/master/tutorials/test_polygon.ipynb), [Polar Curves](https://github.com/byanko55/gemmini/blob/master/tutorials/test_polar.ipynb), [Other Symbols & Shapes](https://github.com/byanko55/gemmini/blob/master/tutorials/test_shape.ipynb)\n* **Apply Transformation to Geometry** - [See here](https://github.com/byanko55/gemmini/blob/master/tutorials/test_transform.ipynb)\n* **Plot Geometry on Python Interactive Window** - [See here](https://github.com/byanko55/gemmini/blob/master/tutorials/test_canvas.ipynb)\n* **Use case with Shapely package** - [See here](https://github.com/byanko55/gemmini/blob/master/tutorials/test_shapely.ipynb)\n* **List of geometrical illustrations** - [All you want is here!](https://github.com/byanko55/gemmini/blob/master/tutorials/test_all.ipynb)\n\n## Contribution\n\nIf you'd like a new shape, transformation, or other mathematical operations to be included, **feel free to leave a issue on this repo**. We are welcome to any kinds of request and feedbacks!",
"bugtrack_url": null,
"license": "",
"summary": "Python package for constructing and handling geometric objects",
"version": "1.0.2",
"project_urls": {
"Homepage": "https://github.com/byanko55/gemmini"
},
"split_keywords": [
"geometry",
"drawing 2d/3d graphic"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6aa9bf8d39bf1b899ace6ec76347a709e3dbac580406876a4a120f8d26d3dbf4",
"md5": "c0fe5bc7ebeb5b0e2fbe4cf64f5fb5f3",
"sha256": "564326b173b262acd77ca43e0b797a42cb6ec0fba1f8fe39b739ebbe0404db72"
},
"downloads": -1,
"filename": "gemmini-1.0.2.tar.gz",
"has_sig": false,
"md5_digest": "c0fe5bc7ebeb5b0e2fbe4cf64f5fb5f3",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 51159,
"upload_time": "2024-03-08T05:37:26",
"upload_time_iso_8601": "2024-03-08T05:37:26.103407Z",
"url": "https://files.pythonhosted.org/packages/6a/a9/bf8d39bf1b899ace6ec76347a709e3dbac580406876a4a120f8d26d3dbf4/gemmini-1.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-08 05:37:26",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "byanko55",
"github_project": "gemmini",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "numpy",
"specs": [
[
">=",
"1.21"
]
]
},
{
"name": "scipy",
"specs": [
[
">=",
"1.7"
]
]
},
{
"name": "matplotlib",
"specs": [
[
">=",
"3.3"
]
]
}
],
"lcname": "gemmini"
}