Skip to main content

A pycairo-compatible 2D vector-graphics backend that renders on the Apple GPU via Metal. Independent project — not affiliated with the cairo project or pycairo.

Project description

cairometal

A pycairo-compatible 2D vector-graphics backend that renders on the Apple GPU via Metal.

Independent project — not affiliated with the cairo graphics library or the official pycairo binding. It reimplements a compatible surface/context API on top of Metal.

Requirements

  • macOS (Apple Silicon). Metal is an Apple framework; there are no Linux/Windows builds.
  • Python 3.10+.

Install

pip install cairometal

Wheels are published per-CPython-version for macOS arm64. There is no on-the-fly compilation at install time — you get a prebuilt binary.

Usage

The API mirrors pycairo, so existing pycairo code largely works by changing the import:

import cairometal as cairo

surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 256, 256)
ctx = cairo.Context(surface)

ctx.set_source_rgb(0.13, 0.42, 0.96)
ctx.rectangle(32, 32, 192, 192)
ctx.fill()

ctx.set_source_rgb(1, 1, 1)
ctx.move_to(60, 140)
ctx.set_font_size(40)
ctx.show_text("Metal")

surface.write_to_png("out.png")   # rasterized on the GPU

What it is

cairometal implements cairo's drawing model — paths, fills, strokes, clips, groups, gradients, text, image surfaces, PNG output — with the rasterization running on the GPU through Metal. It's useful where you have GPU-bound 2D vector work; for light/typical cairo workloads the CPU pycairo is perfectly fine.

License

MIT — see LICENSE.

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

cairometal-0.1.0.tar.gz (324.3 kB view details)

Uploaded Source

Built Distribution

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

cairometal-0.1.0-cp314-cp314-macosx_11_0_arm64.whl (171.6 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

File details

Details for the file cairometal-0.1.0.tar.gz.

File metadata

  • Download URL: cairometal-0.1.0.tar.gz
  • Upload date:
  • Size: 324.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for cairometal-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c339ff7d8dcf3eb06458bb57e77e81bf0dd3458707bebe838797fb38f3522438
MD5 f1a72613b488c8c779645068b5d11cac
BLAKE2b-256 53a8318aa6388bb91db9e08f9977ea64e37e59b783ed8f8bbce87139c8af5296

See more details on using hashes here.

File details

Details for the file cairometal-0.1.0-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cairometal-0.1.0-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fd16cfb531c31d278b96ea67b0a7abc78e363ba83a7484657d4c122d7887e247
MD5 7143501e071bca8b6f8d0e920bbe6ca4
BLAKE2b-256 e565c679d4ea9de4c0a2b37ca4bf40af20ca6b60701d0e15187d8c2367f1f92e

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