taichi.ui.canvas

Module Contents

Classes

Canvas

class taichi.ui.canvas.Canvas(canvas)
set_background_color(self, color)
set_image(self, img)
triangles(self, vertices, color=(0.5, 0.5, 0.5), indices=None, per_vertex_color=None)

Declare a set of 2D triangles inside the scene.

Parameters
  • vertices – a taichi 2D Vector field, where each element indicate the 3D location of a vertex.

  • indices – a taichi int field of shape (3 * #triangles), which indicate the vertex indices of the triangles. If this is None, then it is assumed that the vertices are already arranged in triangles order.

  • color – a global color for the triangles as 3 floats representing RGB values. If per_vertex_color is provided, this is ignored.

  • per_vertex_color (Tuple[float]) – a taichi 3D vector field, where each element indicate the RGB color of a vertex.

lines(self, vertices, width, indices=None, color=(0.5, 0.5, 0.5), per_vertex_color=None)

Declare a set of 2D lines inside the scene.

Parameters
  • vertices – a taichi 2D Vector field, where each element indicate the 3D location of a vertex.

  • width (float) – width of the lines, relative to the height of the screen.

  • indices – a taichi int field of shape (2 * #lines), which indicate the vertex indices of the lines. If this is None, then it is assumed that the vertices are already arranged in lines order.

  • color – a global color for the triangles as 3 floats representing RGB values. If per_vertex_color is provided, this is ignored.

  • per_vertex_color (Tuple[float]) – a taichi 3D vector field, where each element indicate the RGB color of a vertex.

circles(self, centers, radius, color=(0.5, 0.5, 0.5), per_vertex_color=None)

Declare a set of 2D circles inside the scene.

Parameters
  • centers – a taichi 2D Vector field, where each element indicate the 3D location of a vertex.

  • radius (float) – radius of the circles, relative to the height of the screen.

  • color – a global color for the triangles as 3 floats representing RGB values. If per_vertex_color is provided, this is ignored.

  • per_vertex_color (Tuple[float]) – a taichi 3D vector field, where each element indicate the RGB color of a circle.

scene(self, scene)

Draw a 3D scene on the canvas