Skip to main content

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): temp

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


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)

Uploaded Source

Built Distribution

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

tigerpy_drawing-1.0.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

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

Hashes for tigerpy_drawing-1.0.0.tar.gz
Algorithm Hash digest
SHA256 0f245c2f071ed2bd6f643b6af83538a7cbbb11f62c1f48f368838d656ff7f391
MD5 bd92e45c9f79fdca3b424b1c5e39c220
BLAKE2b-256 b13cc72196dbc7c93b74b9e5c62ee9bd77cfda060535b3db55342f518e00abb2

See more details on using hashes here.

File details

Details for the file tigerpy_drawing-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for tigerpy_drawing-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 65c237667500e3dfb2bc4da675ecb8a9ea08b5eae034f2b05f7397c76df9b285
MD5 d417be0bdcdcd5d37521f19deba02048
BLAKE2b-256 b97bec3ea81735dd7b0245e22a24647a613f83f8cd8a8bc631a781563e10a3e5

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