Tigerpy Drawing Python Library
Project description
tigerpy_drawing
Python Drawing Library
This is a Python library, which will enable clients to perform 2D drawing and then export it to SVG.
Client Usage
# client.py
from tigerpy_drawing import DrawingCanvas, Pen
black = (0, 0, 0)
red = (255, 0, 0)
blue = (0, 0, 255)
yellow = (255, 255, 0)
purple = (163, 73, 164)
lightGreen = (128, 255, 128)
green = (34, 177, 76)
blackStrokeAndFillPen = Pen(1, black, black)
redThinPen = Pen(1, red)
blueThickPen = Pen(3, blue)
lightGreenStrokeYelloFillPen = Pen(2, lightGreen, yellow)
purpleStrokeGreenFillPen = Pen(1, purple, green)
# Create a drawing canvas
canvas = DrawingCanvas(300, 300)
# Draw few lines
canvas.SetPen(blackStrokeAndFillPen)
canvas.DrawText(10, 10, "Red 2 pixels thick line")
canvas.SetPen(redThinPen)
canvas.DrawLine(10, 15, 100, 15)
canvas.SetPen(blackStrokeAndFillPen)
canvas.DrawText(10, 35, "Blue 5 pixels thick line")
canvas.SetPen(blueThickPen)
canvas.DrawLine(10, 40, 100, 40)
# Draw Rectangle
canvas.SetPen(blackStrokeAndFillPen)
canvas.DrawText(10, 60, "Filled Rectangle")
canvas.SetPen(lightGreenStrokeYelloFillPen)
canvas.DrawRectangle(10, 65, 40, 40)
# Draw Circle and Ellipse
canvas.SetPen(blackStrokeAndFillPen)
canvas.DrawText(10, 120, "Circle and Ellipse")
canvas.SetPen(redThinPen)
canvas.DrawCircle(40, 160, 30)
canvas.SetPen(redThinPen)
canvas.DrawEllipse(100, 160, 20, 10)
# Draw Polyline
canvas.SetPen(blackStrokeAndFillPen)
canvas.DrawText(10, 220, "Polyline")
canvas.SetPen(redThinPen)
canvas.DrawPolyline([[10, 230], [15, 240], [20, 250], [30, 235], [40, 270]])
# Draw Polygon
canvas.SetPen(blackStrokeAndFillPen)
canvas.DrawText(160, 30, "Polygon")
canvas.SetPen(purpleStrokeGreenFillPen)
canvas.DrawPolygon([[220, 10], [300, 210], [170, 250], [123, 234]])
canvas.ExportSVG("temp.svg")
Run:
> python client.py
Output (screenshot of SVG file opened in Inkscape):
TODOs
- Change font
- Transforms (translation, rotation, scaling)
- Bezier curves
- Export to other image formats: BMP, PNG, JPEG etc
- Draw arrows
- Draw N-gons (like hexagon, octagon etc)
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
tigerpy_drawing-1.0.0.tar.gz
(4.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tigerpy_drawing-1.0.0.tar.gz.
File metadata
- Download URL: tigerpy_drawing-1.0.0.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f245c2f071ed2bd6f643b6af83538a7cbbb11f62c1f48f368838d656ff7f391
|
|
| MD5 |
bd92e45c9f79fdca3b424b1c5e39c220
|
|
| BLAKE2b-256 |
b13cc72196dbc7c93b74b9e5c62ee9bd77cfda060535b3db55342f518e00abb2
|
File details
Details for the file tigerpy_drawing-1.0.0-py3-none-any.whl.
File metadata
- Download URL: tigerpy_drawing-1.0.0-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65c237667500e3dfb2bc4da675ecb8a9ea08b5eae034f2b05f7397c76df9b285
|
|
| MD5 |
d417be0bdcdcd5d37521f19deba02048
|
|
| BLAKE2b-256 |
b97bec3ea81735dd7b0245e22a24647a613f83f8cd8a8bc631a781563e10a3e5
|