Note
Go to the end to download the full example code
Geometry ImageΒΆ
Show an image.
import imageio.v3 as iio
from wgpu.gui.auto import WgpuCanvas, run
import pygfx as gfx
canvas = WgpuCanvas()
renderer = gfx.renderers.WgpuRenderer(canvas)
scene = gfx.Scene()
im = iio.imread("imageio:astronaut.png")[:, :, 1]
image = gfx.Image(
gfx.Geometry(grid=gfx.Texture(im, dim=2)),
gfx.ImageBasicMaterial(clim=(0, 255)),
)
scene.add(image)
camera = gfx.OrthographicCamera(512, 512)
camera.local.position = (256, 256, 0)
camera.local.scale_y = -1
if __name__ == "__main__":
canvas.request_draw(lambda: renderer.render(scene, camera))
run()
Total running time of the script: (0 minutes 0.485 seconds)