Skip to main content

Canvas is a simple Python graphics library using SFML.

Project description

Canvas

Canvas is a small Python graphics library written in SFML.
In the future, Canvas will be bigger and maybe even a famous library, but we can only hope.

Syntax

Setup

First of all, you need to import it.
In your selected terminal, run:

pip install canvas_painter

Then in your Python script (e.g. script.py):

import canvas_painter

Functions

  • canvas.init() Initializes the drawing canvas/window.

  • canvas.load_fonts()
    Loads the default fonts included in the package. You should call this before drawing text.

  • canvas.draw_circle(radius, fill_color, outline_color, outline_thickness, x, y)
    Draw a circle with:

    • radius (int)
    • fill_color (str) — red, green, blue, yellow, cyan, or white (default)
    • outline_color (str)
    • outline_thickness (int)
    • x, y (float) — position coordinates
  • canvas.draw_rectangle(height, length, fill_color, outline_color, outline_thickness, x, y)
    Draw a rectangle with similar parameters to draw_circle.

  • canvas.draw_text(text, font_name, size, color, x, y)
    Draw text string with:

    • text (str) — the string to draw
    • font_name (str) — one of "roboto", "cursive", "figtree", or "lucky"
    • size (int) — font size
    • color (str)
    • x, y (float) — position coordinates
  • canvas.draw_line(x1, y1, x2, y2, color)
    Draw a line between (x1, y1) and (x2, y2) with specified color.

  • canvas.get_mouse_pos()
    Returns the current mouse position relative to the window as an (x, y) tuple.

  • canvas.run()
    Opens the window and starts rendering your shapes and text. This blocks until you close the window.

  • canvas.clear()
    Clears the window content (fill with black). You can call this between frames.

Example

import canvas

canvas.init()
canvas.load_fonts()

canvas.draw_circle(50, "red", "white", 3, 100, 100)
canvas.draw_rectangle(80, 120, "blue", "yellow", 5, 200, 150)
canvas.draw_text("Hello Canvas!", "roboto", 24, "cyan", 50, 30)

canvas.run()

Happy drawing! 🎨✨
If you find bugs or want features, feel free to open an issue or pull request on GitHub.


Canvas is a community project and is still growing.
Thanks for checking it out!

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

canvas_painter-1.0.2.tar.gz (486.7 kB view details)

Uploaded Source

Built Distribution

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

canvas_painter-1.0.2-cp313-cp313-win_amd64.whl (549.7 kB view details)

Uploaded CPython 3.13Windows x86-64

File details

Details for the file canvas_painter-1.0.2.tar.gz.

File metadata

  • Download URL: canvas_painter-1.0.2.tar.gz
  • Upload date:
  • Size: 486.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for canvas_painter-1.0.2.tar.gz
Algorithm Hash digest
SHA256 ea7e47549c4a3763c343e5b2025cd5e217c2d787a5e7d65abd9a5d7b103fb86c
MD5 f42576b8edc98d5ca7f5b49cc3b11a8e
BLAKE2b-256 ce84c00c75edb9b272cd6b7795157a72c37e5365279317debdd16fd6858078f0

See more details on using hashes here.

File details

Details for the file canvas_painter-1.0.2-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for canvas_painter-1.0.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 bfe087c069b5bad0632ded5f0b2c11579f87126e8781bb1183f78ab622d73f82
MD5 24b88fd959900eb130646d432bceb7ec
BLAKE2b-256 09611aac19a101f233896145d5eed50c2e35606ad906c8ade422c569628e204e

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