Skip to content

Commit 053e907

Browse files
authored
Update to readme (#147)
1 parent a5b2653 commit 053e907

File tree

4 files changed

+24
-18
lines changed

4 files changed

+24
-18
lines changed

README.md

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,29 @@ See how the two windows above look the same? That's the idea; they also look the
2121
same to the code that renders to them. Yet, the GUI systems are very different
2222
(Qt vs glfw in this case). Now that's a powerful abstraction!
2323

24-
Coming from `wgpu.gui`? Check [from_wgpu_canvas.md](from_wgpu_canvas.md).
2524

2625

2726
## Purpose
2827

29-
* Provide a generic canvas API to render to.
30-
* Provide an event loop for scheduling events and draws.
31-
* Provide a simple but powerful event system with standardized event objects.
32-
* Provide various canvas implementations:
33-
* One that is light and easily installed (glfw).
34-
* For various GUI libraries (e.g. qt and wx), so visuzalizations can be embedded in a GUI.
35-
* For specific platforms (e.g. Jupyter, browser).
28+
Providing a generic API for:
3629

30+
* managing a canvas window ([`BaseRenderCanvas`](https://rendercanvas.readthedocs.io/stable/api.html)).
31+
* presenting rendered results with `wgpu` ([`WgpuContext`](https://rendercanvas.readthedocs.io/stable/contexts.html#rendercanvas.contexts.WgpuContext)).
32+
* presenting rendered results as a bitmap ([`BitmapContext`](https://rendercanvas.readthedocs.io/stable/contexts.html#rendercanvas.contexts.BitmapContext)).
33+
* working with events that have standardized behavior.
3734

38-
The main use-case is rendering with [wgpu](https://github.com/pygfx/wgpu-py),
39-
but ``rendercanvas``can be used by anything that can render based on a window-id or
40-
by producing bitmap images.
35+
Implement that on top of a variety of backends:
36+
37+
* Running on desktop with a light backend (glfw).
38+
* Running in the browser (with Pyodide or PyScript).
39+
* Running from a (Jupyter) notebook.
40+
* Embedding as a widget in a GUI library.
41+
* Qt
42+
* wx
43+
* In addition to the GUI libraries mentioned above, the following event loops are supported:
44+
* asyncio
45+
* trio
46+
* raw
4147

4248

4349
## Installation
@@ -109,8 +115,8 @@ app.exec()
109115

110116
## Async or not async
111117

112-
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.
113-
If you like callbacks, ``loop.call_later()`` always works. If you like async, use ``loop.add_task()``. Event handlers can always be async.
118+
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.
119+
If you like callbacks, ``loop.call_later()`` always works. If you like async, use ``loop.add_task()``.
114120
See the [docs on async](https://rendercanvas.readthedocs.io/stable/start.html#async) for details.
115121

116122

docs/backends.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ An example using Pyodide directly:
323323
from rendercanvas.auto import RenderCanvas, loop
324324
325325
canvas = RenderCanvas()
326-
context = canvas.get_context("bitmap")
326+
context = canvas.get_bitmap_context()
327327
data = np.random.uniform(127, 255, size=(24, 32, 4)).astype(np.uint8)
328328
329329
@canvas.request_draw

examples/pyodide.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
canvas2_el = document.getElementById("canvas2")
4141
canvas_green = RenderCanvas(canvas_element=canvas2_el, size=(320, 240), update_mode="continuous")
4242
43-
context_red = canvas_red.get_context("bitmap")
44-
context_green = canvas_green.get_context("bitmap")
43+
context_red = canvas_red.get_bitmap_context()
44+
context_green = canvas_green.get_bitmap_context()
4545
4646
red_data = np.random.uniform(127, 255, size=(24, 32, 4)).astype(np.uint8)
4747
red_data[..., 0] = 255

from_wgpu_canvas.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ This document lists all the changes w.r.t. the last version of the canvas in wgp
1111
* `run` -> `loop.run()`.
1212
* `call_later` -> `loop.call_later`.
1313
* `canvas.is_closed()` -> `canvas.get_closed()`.
14-
* The `canvas.get_context()` must be called with an arg: `canvas.get_context("wgpu")`.
14+
* Instead of `canvas.get_context()`, use `canvas.get_wgpu_context()` (or `canvas.get_context('bitmap')`).
1515

1616

1717
## Improvements
1818

1919
* Overall cleaner code, more tests, better docs.
2020
* Support for contexts other than wgpu.
21-
* Bitmap rendering via builtin`canvas.get_context("bitmap")`.
21+
* Bitmap rendering via builtin`canvas.get_bitmap_context()`.
2222
* Handling of sigint (ctrl+c).
2323
* Support for Trio.
2424
* Support for async event handlers.

0 commit comments

Comments
 (0)