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.6+. 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.20.1-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 261c69850d4b2ec03346c9745bad2a835bb8124e4c6961b8ceac503d744eb3b3 |
|
MD5 | 60dd48c60dd0755616467d82272cb0d8 |
|
BLAKE2b-256 | a9f7dcc310cbdaa4c7b5c83231de047fc12f9ada0bd75e8da34f110dd9e9a8d2 |
Hashes for pycairo-1.20.1-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 736ffc618e851601e861a630293e5c910ef016b83b2d035a336f83a367bf56ab |
|
MD5 | 1507a99de1b7dc5f8db97db1db73d525 |
|
BLAKE2b-256 | 40dca584ba160d3396cbd7d4987f6f0aa9efcae78985953c17b977ec85486390 |
Hashes for pycairo-1.20.1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f123d3818e30b77b7209d70a6dcfd5b4e34885f9fa539d92dd7ff3e4e2037213 |
|
MD5 | 5cbac3786814498822b8a00c7353e001 |
|
BLAKE2b-256 | 52e6cfa26e78704acbd3fffe682f60652b2b4a767b5fcdd11568fca08209d9db |
Hashes for pycairo-1.20.1-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e800486b51fffeb11ed867b4f2220d446e2a60a81a73b7c377123e0cbb72f49d |
|
MD5 | 3c9025d8f51b0771c94db96a985dbccd |
|
BLAKE2b-256 | 29cbe87b48d8b394ee37ce387ff18e0bc5977c0190ca4e4147ee9d42457696c5 |
Hashes for pycairo-1.20.1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b605151cdd23cedb31855b8666371b6e26b80f02753a52c8b8023a916b1df812 |
|
MD5 | 7b93ed4c42f3d5c5effb41b6c7348f8f |
|
BLAKE2b-256 | 425a49529130a5a56a81ce740a8759ba3f7769d966d4279a257ed3dcba497a8a |
Hashes for pycairo-1.20.1-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d7a6754d410d911a46f00396bee4be96500ccd3d178e7e98aef1140e3dd67ae |
|
MD5 | 4dc45de793ed32f9c3b896b4c56b9e54 |
|
BLAKE2b-256 | 2e3fb3aed8a1c29ece83a35c325c33078ae8dc4df4f162e1e6c3a0a2c05ab0ba |
Hashes for pycairo-1.20.1-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a32e4a3574a104aa876c35d5e71485dfd6986b18d045534c6ec510c44d5d6a7 |
|
MD5 | 54e804266ba48b4fcf0ba83afccd7317 |
|
BLAKE2b-256 | 98abcc71e76b8ea14abaed84e046e03e121d2b13d3b873f8f6ee4c09f626af63 |
Hashes for pycairo-1.20.1-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8c2bb933974d91c5d19e54b846d964de177e7bf33433bf34ac34c85f9b30e94 |
|
MD5 | 232efc1d018eb7ff8ff550fd55ec5943 |
|
BLAKE2b-256 | 18982c88e7e4860835510ef927a8cb443f663b6fbfc8c2ae0f8822aa94e21d3d |
Hashes for pycairo-1.20.1-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5525da2d8de912750dd157752aa96f1f0a42a437c5625e85b14c936b5c6305ae |
|
MD5 | ac22054c102f30b3db47b3e0c538b012 |
|
BLAKE2b-256 | e8acd987db5443c16dfb28b7e8cc57d35826e5a1ae5122e2cae4e3e834853c51 |
Hashes for pycairo-1.20.1-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6db823a18e7be1eb2a29c28961f2f01e84d3b449f06be7338d05ac8f90592cd5 |
|
MD5 | 85da1db09f80b87b9c56fec458286ef1 |
|
BLAKE2b-256 | 9b59b85904ded680ab15313c09da33232e1293b70d2e0935678b6f5111f8a8cb |