Pan Renderer¶

Copyright 2023 Ethan Christensen

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

class bruhanimate.bruhrenderer.pan_renderer.PanRenderer(screen: Screen, img: List[str], frames: int = 100, frame_time: float = 0.1, effect_type: Literal['static', 'offset', 'noise', 'stars', 'plasma', 'gol', 'rain', 'matrix', 'drawlines', 'snow', 'twinkle', 'audio', 'chat', 'firework', 'fire', 'julia'] = 'static', background: str = ' ', transparent: bool = False, collision: bool = False, direction: Literal['horizontal', 'vertical'] = 'horizontal', shift_rate: int = 1, loop: bool = False)[source]¶

Bases: BaseRenderer

A renderer to pan an image across the screen. Updates the image_buffer only.

__init__(screen: Screen, img: List[str], frames: int = 100, frame_time: float = 0.1, effect_type: Literal['static', 'offset', 'noise', 'stars', 'plasma', 'gol', 'rain', 'matrix', 'drawlines', 'snow', 'twinkle', 'audio', 'chat', 'firework', 'fire', 'julia'] = 'static', background: str = ' ', transparent: bool = False, collision: bool = False, direction: Literal['horizontal', 'vertical'] = 'horizontal', shift_rate: int = 1, loop: bool = False) None[source]¶
validate_direction(direction: Literal['horizontal', 'vertical']) Literal['horizontal', 'vertical'][source]¶

Validates the given direction to ensure it is one of the valid pan renderer directions.

Parameters:

direction (PanRendererDirection) – The direction to be validated.

Returns:

The validated direction.

Return type:

PanRendererDirection

Raises:

InvalidPanRendererDirectionError – If the given direction is not a valid pan renderer direction.

_set_img_attributes() None[source]¶

Sets attributes related to the image, including whether to render it, its height and width, and its initial position on the screen.

property img_size: Tuple[int, int]¶

Gets the size of the image.

Returns:

A tuple containing the height and width of the image. If the image is None or empty, returns (0, 0).

render_img_frame(frame_number: int) None[source]¶

Renders a single frame of the image.

Parameters:

frame_number – The current frame number.

_set_padding(padding_vals: Tuple[int, int]) None[source]¶

Sets the image’s padding based on the provided values.

Parameters:

padding_vals (Tuple[int, int]) – A tuple containing two integers representing the left/right and top/bottom padding.

Returns:

None

Raises:

ValueError – If the provided padding value is invalid or if no image has been set.

render_horizontal_frame(frame_number)[source]¶

Renders a horizontal frame of the image.

Parameters:

frame_number – The current frame number.

render_vertical_frame(frame_number)[source]¶

Renders a vertical frame of the image.

Parameters:

frame_number – The current frame number.