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.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 57166119e424d71eccdba6b318bd731bdabd17188e2ba10d4f315f7bf16ace3f |
|
MD5 | fb4ee60df8f8165e758795fe3c401656 |
|
BLAKE2b-256 | 0fc990de361de52dc2d801f78ec204e369dde9427ea8dffdb8dea4124eccb722 |
Hashes for pycairo-1.20.0-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 57a768f4edc8a9890d98070dd473a812ac3d046cef4bc1c817d68024dab9a9b4 |
|
MD5 | 15265ca8b68c76d90e331b0850846279 |
|
BLAKE2b-256 | 56bd5b3a6c35849ece9f9dde24d6c728a07d98240b3a2424001751a76e169fa0 |
Hashes for pycairo-1.20.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ceb1edcbeb48dabd5fbbdff2e4b429aa88ddc493d6ebafe78d94b050ac0749e2 |
|
MD5 | 44bd1d1e540b1f35a3518b099b55a64f |
|
BLAKE2b-256 | 0194b16f92f4aac89739cb31243bcf4346d2c5ef468db982804ff378e9712589 |
Hashes for pycairo-1.20.0-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2088100a099c09c5e90bf247409ce6c98f51766b53bd13f96d6aac7addaa3e66 |
|
MD5 | 9fa00e23ca380562f211f3a6085a5cf2 |
|
BLAKE2b-256 | eedeeff070f261a4ae2d3ea4fea99ce5e65ada4c631e37cbb3143028d7072ac8 |
Hashes for pycairo-1.20.0-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 273a33c56aba724ec42fe1d8f94c86c2e2660c1277470be9b04e5113d7c5b72d |
|
MD5 | 959638625afe8f6050dea9f299364df9 |
|
BLAKE2b-256 | af7da3db6ae07d90faa5304f9687add30bffa76174919cd83f6df28f53c8504f |
Hashes for pycairo-1.20.0-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8cfa9578b745fb9cf2915ec580c2c50ebc2da00eac2cf4c4b54b63aa19da4b77 |
|
MD5 | 4913b916967c61d21b42bbe46845af70 |
|
BLAKE2b-256 | c650e0776e26f700ed17473fe6d47910e100fcfe92ecc83ac285071b5f65738b |
Hashes for pycairo-1.20.0-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a942614923b88ae75c794506d5c426fba9c46a055d3fdd3b8db7046b75c079cc |
|
MD5 | 7f4080ef71509569c6504e3713e4dc01 |
|
BLAKE2b-256 | 247c02c1b6607fa31ad448133633b60f7a861f1c094eaa49c7139e41474b3c10 |
Hashes for pycairo-1.20.0-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5a3433690c473e073a9917dc8f1fc7dc8b9af7b201bf372894b8ad70d960c6d |
|
MD5 | d29fb6b3618686e64663c97d3b7fe75a |
|
BLAKE2b-256 | 8f2df04b70944f2a0ae496a4ff3c89f613a2cdf1c5c969e89ae317ddc3dde9cd |