Shapes make it easier to generate specific models from data, without having to manipulate AST objects directly.

Shape Types

All shapes are grouped into categories. Click on one of the categories to see a detailed list of shapes.

Base Classes

Inheritance diagram of tangible.shapes.base.BaseShape, tangible.shapes.base.Shape, tangible.shapes.bars.BarsShape, tangible.shapes.vertical.VerticalShape, tangible.shapes.pie.PieShape

class tangible.shapes.base.BaseShape[source]

The base shape.

In contrast to the Shape class, it works without data. It provides a render method and an unimplemented _build_ast stub.


Build the AST and generate code using the selected backend.

Parameters:backend – The backend class used to process the AST. Must accept the AST as constructor argument and provide a generate() method.
Returns:The resulting source code as a string.
class tangible.shapes.base.Shape(data)[source]

The base class for all shapes.

This class provides the base functionality to store data, build an AST and render it using the selected backend.

Parameters:data (sequence type) – The data.
Raises:ValueError if data is empty.
class tangible.shapes.bars.BarsShape(data, bar_width, bar_depth)[source]

Base class for vertical bars.

  • data (sequence type) – The data.
  • bar_width (int or float) – The width of each bar.
  • bar_depth (int or float) – The depth of each bar.
class tangible.shapes.vertical.VerticalShape(data, layer_height)[source]

Base class for vertical shapes like towers.

  • data (sequence type) – The data.
  • layer_height (int or float) – The height of each layer in the vertical shape.
class tangible.shapes.pie.PieShape(data, height=2, outer_radius=10, inner_radius=0, explode=0)[source]

Base class for pie shapes.

  • data (sequence type) – The data.
  • height (int or float) – The height of the model (default 2).
  • outer_radius (int or float) – The outer radius of the model (default 10).
  • inner_radius (int or float) – The inner radius of the model (default 0).
  • explode (int or float) – By how much to explode the sectors (default 0).

Inheritance Diagram

Inheritance diagram of tangible.shapes.base, tangible.shapes.bars, tangible.shapes.vertical, tangible.shapes.pie