Focus 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.focus_renderer.FocusRenderer(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, start_frame: int = 0, reverse: bool = False, start_reverse: int = None, loop: bool = True)[source]¶

Bases: BaseRenderer

A Renderer that takes an image and randomly spreads the characters around the screen. The characters are then pulled to the middle of the screen

__init__(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, start_frame: int = 0, reverse: bool = False, start_reverse: int = None, loop: bool = True)[source]¶
_set_img_attributes()[source]¶

Sets attributes for the image, such as its height and width, and initializes boards to track character positions.

update_reverse(reverse: bool, start_reverse: int) None[source]¶

Updates the state of reverse and start_reverse attributes.

Parameters:
  • reverse (bool) – Whether to enable or disable reverse.

  • start_reverse (int) – The frame number at which to start the reverse.

Raises:

Exception – If reverse is enabled but start_reverse is not provided, or if start_reverse is less than the current start_frame.

update_start_frame(frame_number)[source]¶

Updates the state of the start frame attribute.

Parameters:

frame_number (int) – The new start frame number.

Returns:

None

solved(end_state)[source]¶

Checks whether the current board is in a desired state.

Parameters:

end_state (str) – The desired state to check against. Can be “end”, “start”, or any other value for custom checks.

Returns:

Whether the current board matches the desired state.

Return type:

bool

render_img_frame(frame_number)[source]¶

Renders the image on the screen based on the current frame number.

Parameters:

frame_number (int) – The current frame number.

Returns:

None