Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweak examples #12

Merged
merged 2 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions examples/cube_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,10 @@


canvas = RenderCanvas(
size=(640, 480), title=f"The wgpu cube example on a {RenderCanvas.__name__}"
title="The wgpu cube example on $backend", update_mode="continuous"
)
draw_frame = setup_drawing_sync(canvas)


@canvas.request_draw
def animate():
draw_frame()
canvas.request_draw()
canvas.request_draw(draw_frame)


if __name__ == "__main__":
Expand Down
11 changes: 4 additions & 7 deletions examples/cube_glfw.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,11 @@
from rendercanvas.utils.cube import setup_drawing_sync


canvas = RenderCanvas(size=(640, 480), title="The wgpu cube example on glfw")
canvas = RenderCanvas(
title="The wgpu cube example on $backend", update_mode="continuous"
)
draw_frame = setup_drawing_sync(canvas)


@canvas.request_draw
def animate():
draw_frame()
canvas.request_draw()
canvas.request_draw(draw_frame)


if __name__ == "__main__":
Expand Down
23 changes: 23 additions & 0 deletions examples/cube_offscreen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""
Render a wgpu example offscreen, and display as an image.
"""

import os
import tempfile
import webbrowser

import imageio.v3 as iio
from rendercanvas.offscreen import RenderCanvas
from rendercanvas.utils.cube import setup_drawing_sync


canvas = RenderCanvas(size=(640, 480), pixel_ratio=2)
draw_frame = setup_drawing_sync(canvas)
canvas.request_draw(draw_frame)

image = canvas.draw()
assert image.shape == (960, 1280, 4)

filename = os.path.join(tempfile.gettempdir(), "rendercanvasexample.png")
iio.imwrite(filename, image)
webbrowser.open("file://" + filename)
10 changes: 2 additions & 8 deletions examples/cube_qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,12 @@


from rendercanvas.qt import RenderCanvas, run

from rendercanvas.utils.cube import setup_drawing_sync


canvas = RenderCanvas(size=(640, 480), title=f"The wgpu cube example on {lib}")
canvas = RenderCanvas(title=f"The wgpu cube example on {lib}", update_mode="continuous")
draw_frame = setup_drawing_sync(canvas)


@canvas.request_draw
def animate():
draw_frame()
canvas.request_draw()
canvas.request_draw(draw_frame)


if __name__ == "__main__":
Expand Down
11 changes: 4 additions & 7 deletions examples/cube_wx.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,11 @@
from rendercanvas.utils.cube import setup_drawing_sync


canvas = RenderCanvas(size=(640, 480), title="The wgpu cube example on wx")
canvas = RenderCanvas(
title="The wgpu cube example on $backend", update_mode="continuous"
)
draw_frame = setup_drawing_sync(canvas)


@canvas.request_draw
def animate():
draw_frame()
canvas.request_draw()
canvas.request_draw(draw_frame)


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion examples/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@


draw_frame = setup_drawing_sync(canvas)
canvas.request_draw(lambda: (draw_frame(), canvas.request_draw()))
canvas.request_draw(draw_frame)


@canvas.add_event_handler("*")
Expand Down
4 changes: 2 additions & 2 deletions examples/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
from rendercanvas.auto import RenderCanvas, run


canvas = RenderCanvas(size=(640, 480), title="RenderCanvas events")
canvas = RenderCanvas(title="RenderCanvas events")


@canvas.add_event_handler("*")
def process_event(event):
if event["event_type"] != "pointer_move":
if event["event_type"] not in ["pointer_move", "before_draw", "draw"]:
print(event)


Expand Down
14 changes: 6 additions & 8 deletions examples/multiple.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
"""
Run triangle and cube examples two canvases.
Run cube example in two canvases.
"""

# test_example = true

from rendercanvas.auto import RenderCanvas, loop

from triangle import setup_drawing_sync as setup_drawing_sync_triangle
from cube import setup_drawing_sync as setup_drawing_sync_cube
from rendercanvas.utils.cube import setup_drawing_sync


canvas1 = RenderCanvas(title=f"Triangle example on {RenderCanvas.__name__}")
draw_frame1 = setup_drawing_sync_triangle(canvas1)
canvas1 = RenderCanvas(title="$backend 1", update_mode="continuous")
draw_frame1 = setup_drawing_sync(canvas1)
canvas1.request_draw(draw_frame1)

canvas2 = RenderCanvas(title=f"Cube example on {RenderCanvas.__name__}")
draw_frame2 = setup_drawing_sync_cube(canvas2)
canvas2 = RenderCanvas(title="$backend 2", update_mode="continuous")
draw_frame2 = setup_drawing_sync(canvas2)
canvas2.request_draw(draw_frame2)


Expand Down
2 changes: 1 addition & 1 deletion examples/offsceen_threaded.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from rendercanvas.offscreen import RenderCanvas

from cube import setup_drawing_sync
from rendercanvas.utils.cube import setup_drawing_sync


# create canvas
Expand Down
1 change: 0 additions & 1 deletion examples/qt_app_asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ def __init__(self):

splitter = QtWidgets.QSplitter()

# todo: use update_mode = 'continuous' when that feature has arrived
self.button = QtWidgets.QPushButton("Hello world", self)
self.canvas = QRenderWidget(splitter, update_mode="continuous")
self.output = QtWidgets.QTextEdit(splitter)
Expand Down
136 changes: 136 additions & 0 deletions examples/rendercanvas.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "afd9b3fd",
"metadata": {},
"source": [
"# RenderCanvas notebook examples"
]
},
{
"cell_type": "markdown",
"id": "e120b752",
"metadata": {},
"source": [
"## Cube example"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "e4f9f67d",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "f13251ba883843a39be8a9a6b4e76970",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"RFBOutputContext()"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "fecfdbe30cef480da747f15986df29da",
"version_major": 2,
"version_minor": 0
},
"text/html": [
"<div class='snapshot-fecfdbe30cef480da747f15986df29da' style='position:relative;'><img src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAoAAAAHgCAYAAAA10dzkAAAhnUlEQVR42u3dW7Idt5FAUY1Io/KcPCaPqjvsCCkkipf3dQobQK6P9Z91gKrcTVrs33777bf/AwBglHwAAADWygcAAGCtfAAAANbKBwAAYK18AAAA1soHAABgrXwAAADWygcAAGCtfAAAANbKBwAAYK18AAAA1soHAABgrXwAAADWygcAAGCtfAAAANbKBwAAYK18AAAA1soHAABgrXwAAADWygcAAGCtfAAAANbKBwAAYK18AAAA1soHAABgrXwAAADWygcAAGCtfAAAANbKBwAAYK18AAAA1soHAABgrXwAAADWygcAAGCtfAAAANbKBwAAYK18AAAA1soHAABgrXwAAADWygcAAGCtfAAAANbKBwAAYK18AAAA1soHAABgrXwAAADWygcADvOf//znb+p5APi0fADgED+G36/UswLwS/kAwOY+E37CEOAI+QDApl4ZfsIQYCv5AMBmVoafKARI5AMAm6iDTxgCLJMPAMTqoBOFAMvlAwCROtqEIUAmHwBYrI6yHdRnABDLBwAWqaNrd/X5ACyUDwA8rA6r09XnB/CAfADgIXU43ebf//73n+qzBfimfADgxepQus1fw+899dkDfFA+APACdSTd6DPhJwyBw+QDAN9QR9KNXhl+ohDYVD4A8AV1JN1mVfQJQ2AT+QDAJ9ShdJs69oQhEMkHAD6gDqXb1DEnCoFYPgDwC7///vv/1MF0izrYhCGwiXwA4Cf+CL/31EF1ijrIdlDfaWAr+QDAX3w0/ESh8BOGwDfkAwC/vSb8hKHwE4bAB+UDwGgrwm9SGNbRdJt//etff1O/L8DL5APASHX03RaFdSjd5sfwe0/9PgGflg8Ao9Rhd1sY1qF0m8+GnyiEY+UDwAh1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xwOwfl+AfgDgIXWUCUABKPxgW/kAwGJ1rAnAeQFY33ngH/IBgE3UEScA7wvA+k4Db8oHADZWh50APDMA63sLvCsfADhQHXwCcM8ArO8l8GH5AMAlBODcAKzvHvBp+QDA5QTgvQFY3y3gy/IBgKEE4LkBWN8d4NvyAQD+JAD3DsD6fgAvkw8A8C4B2AVgffbAI/IBAL5MAAo/4EvyAQBeqo6y0wOwPj9giXwAgCXqWNs9AOvzAZbKBwDI1AG3QwDWZwAk8gEAtlOH3YoArH9jIJUPAHCMOvheEYD1bwhsIR8A4GinBGD9OwFbyQcAuNIuAVj/DsCW8gEAxlgZgPWzAlvLBwAY75UBWD8LcIR8AADe8JkArGcFjpIPAMAn/BiA9TzAkfIBAABYKx8AAIC18gEAAFgrHwAAgLXyAQAAWCsfAACAtfIBAABYKx8AAIC18gEAAFgrHwAAgLXyAQAAWCsfAACAtfIBAABYKx8AAIC18gEAAFgrHwAAgLXyAQAAWCsfAACAtfIBAABYKx8AAIC18gEAAFgrHwAAgLXyAQAAWCsfAACAtfIBAABYKx8AAIC18gEAAFgrHwAAgLXyAQAAWCsfAACAtfIBAABYKx8AAIC18gEAAFgrHwAAgLXyAQAAWCsfAACAtfIBAABYKx8AAIC18gEAAFgrHwAAgLXyAQAAWCsfAACAtfIBAABYKx8AAICF/h8/1G8ZG1lRHAAAAABJRU5ErkJggg==' style='width:640.0px;height:480.0px;' /><div style='position: absolute; top:0; left:0; padding:1px 3px; background: #777; color:#fff; font-size: 90%; font-family:sans-serif; '>snapshot</div></div>"
],
"text/plain": [
"JupyterRenderCanvas(css_height='480.0px', css_width='640.0px')"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from rendercanvas.utils.cube import setup_drawing_sync\n",
"from rendercanvas.auto import RenderCanvas\n",
"\n",
"canvas = RenderCanvas(update_mode=\"continuous\")\n",
"draw_frame = setup_drawing_sync(canvas)\n",
"canvas.request_draw(draw_frame)\n",
"\n",
"canvas"
]
},
{
"cell_type": "markdown",
"id": "749ffb40",
"metadata": {},
"source": [
"## Events"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "6d0e64b7-a208-4be6-99eb-9f666ab8c2ae",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "d4b7240a4cbf4b5686ab11c6c1c480eb",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Textarea(value='', rows=10)"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import ipywidgets\n",
"\n",
"out = ipywidgets.Textarea(rows=10)\n",
"\n",
"\n",
"@canvas.add_event_handler(\"*\")\n",
"def show_events(event):\n",
" if event[\"event_type\"] not in [\"pointer_move\", \"before_draw\", \"draw\"]:\n",
" out.value = str(event)\n",
"\n",
"\n",
"out"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.4"
}
},
"nbformat": 4,
"nbformat_minor": 5
}