Geometry, vectors, colors, and text#
Geometry helpers, vector math, colormaps, and text/label rendering.
Geometry and vectors#
- class webgpu.vectors.BaseVectorRenderer(label='VectorField')#
Bases:
Renderer- create_vector_data()#
- get_bindings()#
- get_shader_code()#
- n_vertices: int = 10#
- render(encoder)#
- topology: PrimitiveTopology = 'triangle-strip'#
- update(timestamp)#
- class webgpu.vectors.VectorRenderer(points, vectors, size=None, scale_with_vector_length=False)#
Bases:
BaseVectorRenderer- get_bounding_box()#
- update(timestamp)#
- class webgpu.vectors.VectorUniform(**kwargs)#
Bases:
UniformBase- scale_veclen#
Structure/Union member
- size#
Structure/Union member
Colors and colormaps#
- class webgpu.colormap.Colorbar(
- colormap: Colormap | None = None,
- position=(-0.9, 0.9),
- width=1,
- height=0.05,
- number_format=None,
Bases:
Renderer- add_options_to_gui(gui)#
- fragment_entry_point: str = 'colormap_fragment'#
- get_bindings()#
- get_shader_code()#
- property height#
- n_vertices: int = 3#
- property position#
- render(options: RenderOptions)#
- select_entry_point: str = ''#
- set_max(maxval)#
- set_min(minval)#
- update(options: RenderOptions)#
- vertex_entry_point: str = 'colormap_vertex'#
- property width#
- class webgpu.colormap.ColorbarUniforms(**kwargs)#
Bases:
UniformBase- height#
Structure/Union member
- position#
Structure/Union member
- width#
Structure/Union member
- class webgpu.colormap.Colormap(
- minval=None,
- maxval=None,
- colormap: list | str = 'matlab:jet',
- n_colors=8,
Bases:
BaseRenderer- get_bindings()#
- set_colormap(colormap: list | str)#
- set_discrete(discrete: bool)#
- set_max(maxval)#
- set_min(minval)#
- set_min_max(minval, maxval, set_autoscale=True)#
- set_n_colors(n_colors)#
- update(options: RenderOptions)#
- class webgpu.colormap.ColormapUniforms(**kwargs)#
Bases:
UniformBase- discrete#
Structure/Union member
- max#
Structure/Union member
- min#
Structure/Union member
- n_colors#
Structure/Union member
- webgpu.colormap.create_colormap(name: str, n_colors: int = 32)#
Create a colormap with the given name and number of colors.
Text and labels#
- class webgpu.labels.Labels(
- labels: list[str],
- positions: list[tuple],
- apply_camera: bool | list[bool] = False,
- h_align: str | list[str] = 'left',
- v_align: str | list[str] = 'bottom',
- font_size=20,
Bases:
Renderer- fragment_entry_point: str = 'fragmentFont'#
- get_bindings()#
- get_shader_code()#
- n_vertices: int = 6#
Render a list of strings on screen @param labels: list of strings to render @param positions: list of positions to render the labels at @param apply_camera: whether to apply the camera transformation to the labels @param h_align: horizontal alignment of the labels. Can be one of: left, l, center, c, right, r @param v_align: horizontal alignment of the labels. Can be one of: bottom, b, center, c, top, t @param font_size: font size
If any of apply_camera, h_align, or v_align is a list, it must have the same length as labels.
- select_entry_point: str = ''#
- update(options: RenderOptions)#
- vertex_entry_point: str = 'vertexText'#
- class webgpu.font.FontAtlas(
- char_width: int,
- char_height: int,
- x_shift: int,
- y_shift: int,
- chars_per_row: int,
- n_rows: int,
- font_size: float,
- charset: str,
- image: numpy.ndarray,
- texture: webgpu.webgpu_api.Texture | None = None,
- texture_sampler: webgpu.webgpu_api.Sampler | None = None,
- char_map: dict[int, int] = None,
- advance: float = 1.0,
Bases:
object- char_height: int#
- char_map: dict[int, int] = None#
- char_width: int#
- chars_per_row: int#
- charset: str#
- get_uniform_settings()#
- image: ndarray#
- classmethod load(filepath: str | Path)#
- n_rows: int#
- save(filepath: str | Path)#
- update()#
- x_shift: int#
- y_shift: int#
- class webgpu.font.FontUniforms(**kwargs)#
Bases:
UniformBase- advance#
Structure/Union member
- aspect#
Structure/Union member
- chars_per_row#
Structure/Union member
- font_size#
Structure/Union member
- n_rows#
Structure/Union member
- padding#
Structure/Union member
- size#
Structure/Union member
- size_scaling#
Structure/Union member
- x_shift#
Structure/Union member
- y_shift#
Structure/Union member
- webgpu.font.get_font_atlas()#