cirq.TextDiagramDrawer

A utility class for creating simple text diagrams.

Methods

content_present

View source

Determines if a line or printed text is at the given location.

copy

View source

force_horizontal_padding_after

View source

Change the padding after the given column.

force_vertical_padding_after

View source

Change the padding after the given row.

grid_line

View source

Adds a vertical or horizontal line from (x1, y1) to (x2, y2).

Horizontal line is selected on equality in the second coordinate and vertical line is selected on equality in the first coordinate.

Raises
ValueError If line is neither horizontal nor vertical.

height

View source

Determines how many entry rows are in the diagram.

horizontal_line

View source

Adds a line from (x1, y) to (x2, y).

hstack

View source

Horizontally stack text diagrams.

Args
diagrams The diagrams to stack, ordered from left to right.
padding_resolver A function that takes a list of paddings specified for a row and returns the padding to use in the stacked diagram. Defaults to raising ValueError if the diagrams to stack contain inconsistent padding in any row, including if some specify a padding and others don't.

Raises
ValueError Inconsistent padding cannot be resolved.

Returns
The horizontally stacked diagram.

insert_empty_columns

View source

Insert a number of columns after the given column.

insert_empty_rows

View source

Insert a number of rows after the given row.

render

View source

Outputs text containing the diagram.

shift

View source

shifted

View source

superimpose

View source

superimposed

View source

transpose

View source

Returns the same diagram, but mirrored across its diagonal.

vertical_line

View source

Adds a line from (x, y1) to (x, y2).

vstack

View source

Vertically stack text diagrams.

Args
diagrams The diagrams to stack, ordered from bottom to top.
padding_resolver A function that takes a list of paddings specified for a column and returns the padding to use in the stacked diagram. If None, defaults to raising ValueError if the diagrams to stack contain inconsistent padding in any column, including if some specify a padding and others don't.

Raises
ValueError Inconsistent padding cannot be resolved.

Returns
The vertically stacked diagram.

width

View source

Determines how many entry columns are in the diagram.

write

View source

Adds text to the given location.

Args
x The column in which to write the text.
y The row in which to write the text.
text The text to write at location (x, y).
transposed_text Optional text to write instead, if the text diagram is transposed.

__bool__

View source

__eq__

View source

__ne__

View source