diff --git a/README.md b/README.md index 897e45e..58ffd86 100644 --- a/README.md +++ b/README.md @@ -21,23 +21,29 @@ 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](from_wgpu_canvas.md). ## Purpose -* Provide a generic canvas API to render to. -* Provide an event loop for scheduling events and draws. -* Provide a simple but powerful event system with standardized event objects. -* Provide various canvas implementations: - * One that is light and easily installed (glfw). - * For various GUI libraries (e.g. qt and wx), so visuzalizations can be embedded in a GUI. - * For specific platforms (e.g. Jupyter, browser). +Providing a generic API for: +* managing a canvas window ([`BaseRenderCanvas`](https://rendercanvas.readthedocs.io/stable/api.html)). +* presenting rendered results with `wgpu` ([`WgpuContext`](https://rendercanvas.readthedocs.io/stable/contexts.html#rendercanvas.contexts.WgpuContext)). +* presenting rendered results as a bitmap ([`BitmapContext`](https://rendercanvas.readthedocs.io/stable/contexts.html#rendercanvas.contexts.BitmapContext)). +* working with events that have standardized behavior. -The main use-case is rendering with [wgpu](https://github.com/pygfx/wgpu-py), -but ``rendercanvas``can be used by anything that can render based on a window-id or -by producing bitmap images. +Implement that on top of a variety of backends: + +* Running on desktop with a light backend (glfw). +* Running in the browser (with Pyodide or PyScript). +* Running from a (Jupyter) notebook. +* Embedding as a widget in a GUI library. + * Qt + * wx +* In addition to the GUI libraries mentioned above, the following event loops are supported: + * asyncio + * trio + * raw ## Installation @@ -109,8 +115,8 @@ app.exec() ## Async or not async -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. +We support both; a render canvas can be used in a fully async setting using e.g. Asyncio or Trio, or in an event-driven framework like Qt. +If you like callbacks, ``loop.call_later()`` always works. If you like async, use ``loop.add_task()``. See the [docs on async](https://rendercanvas.readthedocs.io/stable/start.html#async) for details. diff --git a/docs/backends.rst b/docs/backends.rst index 4b99998..11811ba 100644 --- a/docs/backends.rst +++ b/docs/backends.rst @@ -323,7 +323,7 @@ An example using Pyodide directly: from rendercanvas.auto import RenderCanvas, loop canvas = RenderCanvas() - context = canvas.get_context("bitmap") + context = canvas.get_bitmap_context() data = np.random.uniform(127, 255, size=(24, 32, 4)).astype(np.uint8) @canvas.request_draw diff --git a/examples/pyodide.html b/examples/pyodide.html index 67a1619..7796837 100644 --- a/examples/pyodide.html +++ b/examples/pyodide.html @@ -40,8 +40,8 @@ canvas2_el = document.getElementById("canvas2") canvas_green = RenderCanvas(canvas_element=canvas2_el, size=(320, 240), update_mode="continuous") - context_red = canvas_red.get_context("bitmap") - context_green = canvas_green.get_context("bitmap") + context_red = canvas_red.get_bitmap_context() + context_green = canvas_green.get_bitmap_context() red_data = np.random.uniform(127, 255, size=(24, 32, 4)).astype(np.uint8) red_data[..., 0] = 255 diff --git a/from_wgpu_canvas.md b/from_wgpu_canvas.md index c8efb1f..8b3483c 100644 --- a/from_wgpu_canvas.md +++ b/from_wgpu_canvas.md @@ -11,14 +11,14 @@ This document lists all the changes w.r.t. the last version of the canvas in wgp * `run` -> `loop.run()`. * `call_later` -> `loop.call_later`. * `canvas.is_closed()` -> `canvas.get_closed()`. -* The `canvas.get_context()` must be called with an arg: `canvas.get_context("wgpu")`. +* Instead of `canvas.get_context()`, use `canvas.get_wgpu_context()` (or `canvas.get_context('bitmap')`). ## Improvements * Overall cleaner code, more tests, better docs. * Support for contexts other than wgpu. -* Bitmap rendering via builtin`canvas.get_context("bitmap")`. +* Bitmap rendering via builtin`canvas.get_bitmap_context()`. * Handling of sigint (ctrl+c). * Support for Trio. * Support for async event handlers.