Python interface for cairo
Project description
Pycairo is a Python module providing bindings for the cairo graphics library. It depends on cairo >= 1.15.10 and works with Python 3.7+. Pycairo, including this documentation, is licensed under the LGPL-2.1-only OR MPL-1.1.
The Pycairo bindings are designed to match the cairo C API as closely as possible, and to deviate only in cases which are clearly better implemented in a more ‘Pythonic’ way.
pip install pycairo
Installing Pycairo requires cairo including its headers. For more info see “Getting Started”.
import cairo
with cairo.SVGSurface("example.svg", 200, 200) as surface:
context = cairo.Context(surface)
x, y, x1, y1 = 0.1, 0.5, 0.4, 0.9
x2, y2, x3, y3 = 0.6, 0.1, 0.9, 0.5
context.scale(200, 200)
context.set_line_width(0.04)
context.move_to(x, y)
context.curve_to(x1, y1, x2, y2, x3, y3)
context.stroke()
context.set_source_rgba(1, 0.2, 0.2, 0.6)
context.set_line_width(0.02)
context.move_to(x, y)
context.line_to(x1, y1)
context.move_to(x2, y2)
context.line_to(x3, y3)
context.stroke()
Features of the Pycairo bindings:
Provides an object oriented interface to cairo.
Queries the error status of objects and translates them to exceptions.
Provides a C API that can be used by other Python extensions.
If Pycairo is not what you need, have a look at cairocffi, which is an API compatible package using cffi or Qahirah, which is using ctypes and provides a more “pythonic” API with less focus on matching the cairo C API.
For more information visit https://pycairo.readthedocs.io
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
Built Distributions
Hashes for pycairo-1.21.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f63c153a9ea3d21aff85e2caeee4b0c5d566b2368b4ed64826020d12953d76a4 |
|
MD5 | cc5a1387f3fc7e96259735e35d1e4066 |
|
BLAKE2b-256 | 39376e30254f6583a8ecf6f8a103af48ef5f8c97f56bbe94cf69af6f5f80729c |
Hashes for pycairo-1.21.0-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44a2ecf34968de07b3b9dfdcdbccbd25aa3cab267200f234f84e81481a73bbf6 |
|
MD5 | 282226b27d01a45ac7d203eb3159d3c9 |
|
BLAKE2b-256 | 9da4783deb9a62eb4417f2660dba97de7e3c8e22f6a9840aea294679b172ba10 |
Hashes for pycairo-1.21.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26b72b813c6f9d495f71057eab89c13e70a21c92360e9265abc049e0a931fa39 |
|
MD5 | 415bbe70e03a15c8798ffd1b5147e385 |
|
BLAKE2b-256 | c51573cdbade21b101e679a344c519e402948dadbc159e03bef6738317e8c2c4 |
Hashes for pycairo-1.21.0-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d37375aab9f2bb6136f076c19815d72108383baae89fbc0d6cb8e5092217d02 |
|
MD5 | 5c013b2b6c51d2732430dafad2bdf60f |
|
BLAKE2b-256 | f14ce9149c9135ad0644b906f7890fd70502bd01f95b12e4dddfa39784826c0d |
Hashes for pycairo-1.21.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4357f20a6b1de8f1e8072a74ff68ab4c9a0ae698cd9f5c0f2b2cdd9b28b635f6 |
|
MD5 | b5e4e429b62ea4a1cfaabd703c1f8117 |
|
BLAKE2b-256 | bc0a62f8f61cceeec8b717b96d8773da5b2897ed6017206e1360f1694fac5e62 |
Hashes for pycairo-1.21.0-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dace6b356c476de27f8e1522428ac21a799c225703f746e2957d441f885dcb6c |
|
MD5 | b029488101b1f1012f9991fa81cc8a52 |
|
BLAKE2b-256 | 012cb26441fa33a8beb905bb893eb5368b6b2c713a0edd5284356c6f4cffd863 |
Hashes for pycairo-1.21.0-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31e1c4850db03201d33929cbe1905ce1b33202683ebda7bb0d4dba489115066b |
|
MD5 | 78b9c4248786635341fa3b570a89e0d4 |
|
BLAKE2b-256 | 482d1c040c138201d4c20e426ed7edbc4baead044e6b1706858d1fe3fdd3fc56 |
Hashes for pycairo-1.21.0-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 70936b19f967fa3cb3cd200c2608911227fa5d09dae21c166f64bc15e714ee41 |
|
MD5 | dfef1d4fc599c964abe74acbf6b497b8 |
|
BLAKE2b-256 | 5d260d193f24c683edf71864a28d87e19f0015c2c639bf9dd0cc2b96c4a8b18e |