![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
One canvas API, multiple backends 🚀
This project is part of pygfx.org
See how the two windows above look the same? That's the idea; they also look the same to the code that renders to them. Yet, the GUI systems are very different (Qt vs glfw in this case). Now that's a powerful abstraction!
Coming from wgpu.gui
? Check from_wgpu_canvas.md.
The main use-case is rendering with wgpu,
but rendercanvas
can be used by anything that can render based on a window-id or
by producing bitmap images.
pip install rendercanvas
To have at least one backend, we recommend:
pip install rendercanvas glfw
Also see the online documentation and the examples.
A minimal example that renders noise:
import numpy as np
from rendercanvas.auto import RenderCanvas, loop
canvas = RenderCanvas(update_mode="continuous")
context = canvas.get_context("bitmap")
@canvas.request_draw
def animate():
w, h = canvas.get_logical_size()
bitmap = np.random.uniform(0, 255, (h, w)).astype(np.uint8)
context.set_bitmap(bitmap)
loop.run()
Run wgpu visualizations:
from rendercanvas.auto import RenderCanvas, loop
from rendercanvas.utils.cube import setup_drawing_sync
canvas = RenderCanvas(
title="The wgpu cube example on $backend", update_mode="continuous"
)
draw_frame = setup_drawing_sync(canvas)
canvas.request_draw(draw_frame)
loop.run()
Embed in a Qt application:
from PySide6 import QtWidgets
from rendercanvas.qt import QRenderWidget
class Main(QtWidgets.QWidget):
def __init__(self):
super().__init__()
splitter = QtWidgets.QSplitter()
self.canvas = QRenderWidget(splitter)
...
app = QtWidgets.QApplication([])
main = Main()
app.exec()
We support both; a render canvas can be used in a fully async setting using e.g. Asyncio or Trio, or in an event-drived framework like Qt.
If you like callbacks, loop.call_later()
always works. If you like async, use loop.add_task()
. Event handlers can always be async.
See the docs on async for details.
This code is distributed under the 2-clause BSD license.
rendercanvas
and developer deps using pip install -e .[dev]
.ruff format
to apply autoformatting.ruff check
to check for linting errors.pre-commit install
, lint fixes and formatting will be automatically applied on git commit
.pytest tests
to run the tests.pytest examples
to run a subset of the examples.FAQs
One canvas API, multiple backends
We found that rendercanvas demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.