Skip to content

Helpers

code_video.AutoScaled

Autoscales whatever it wraps on changes in placement including:

  • next_to
  • to_edge
  • set_x
  • set_y
  • move_to

code_video.ColumnLayout

Helper to determine X values for a column layout

get_x(self, column, span=1, direction=array([-1., 0., 0.]))

Gets the x value for a given column and span.

Parameters:

Name Type Description Default
column int

The column number, with 1 as the first column

required
span

The number of columns to span

1
direction

The direction of the X value, LEFT or RIGHT

array([-1., 0., 0.])
Source code in code_video/layout.py
def get_x(self, column: int, span=1, direction=LEFT) -> float:
    """
    Gets the x value for a given column and span.

    Args:
        column: The column number, with 1 as the first column
        span: The number of columns to span
        direction: The direction of the X value, `LEFT` or `RIGHT`
    """
    col = column - 1

    x_left = self.left_x + col * self.column_width + self.buff
    x_right = self.left_x + (col + span) * self.column_width - self.buff

    if np.all(direction == LEFT):
        return x_left
    elif np.all(direction == RIGHT):
        return x_right
    else:
        raise ValueError