Skip to content
View psblah's full-sized avatar

Block or report psblah

Block user

Prevent this user from interacting with your repositories and sending you notifications. Learn more about blocking users.

You must be logged in to block users.

Please don't include any personal information such as legal names or email addresses. Maximum 100 characters, markdown supported. This note will be visible to only you.
Report abuse

Contact GitHub support about this user’s behavior. Learn more about reporting abuse.

Report abuse
psblah/README.md

Hi there 👋

 ___     ___     ____      _           ___      _    _
|    |  /  ___|  |  _ \   | |         /   |    | |  | |
| /| |  \ `--.   | |_) |  | |        / /| |    | |__| |
| ___|   `--. \  |  _ <   | |       / / | |    |  __  |
| |     /\__/    | |_) |  | |___   /  ___ |    | |  | |
|_|     \____/   |____/   |_____|  \/  |_|     |_|  |_|
from dataclasses import dataclass
from typing import Dict, List, Optional
import asyncio
from functools import reduce
from enum import Enum
import logging
from datetime import datetime

# Configure logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

class CharacterType(Enum):
    STANDARD = "standard"
    SPECIAL = "special"

@dataclass(frozen=True)
class ASCIIConfig:
    rows: int = 6
    spacing: str = "  "  # Double space between characters
    default_width: int = 8  # Increased default width

@dataclass
class ASCIICharacter:
    char: str
    matrix: List[str]
    type: CharacterType = CharacterType.STANDARD
    
    def __post_init__(self):
        if len(self.matrix) != ASCIIConfig.rows:
            raise ValueError(f"Character {self.char} must have exactly {ASCIIConfig.rows} rows")

class ASCIIArtMatrix:
    def __init__(self):
        self._character_map: Dict[str, ASCIICharacter] = {
            'P': ASCIICharacter('P', [
                ' ___  ', '|    |', '| /| |', '| ___|', '| |   ', '|_|   '
            ]),
            'S': ASCIICharacter('S', [
                ' ___  ', '/  ___|', '\\ `--. ', ' `--. \\', '/\\__/  ', '\\____/ '
            ], CharacterType.SPECIAL),
            'B': ASCIICharacter('B', [
                ' ____   ', '|  _ \\ ', '| |_) |', '|  _ < ', '| |_) |', '|____/ '
            ], CharacterType.SPECIAL),
            'L': ASCIICharacter('L', [
                ' _        ', '| |       ', '| |      ', '| |     ', '| |___ ', '|_____|'
            ]),
            'A': ASCIICharacter('A', [
                ' ___   ', '/   |  ', '/ /| |  ', '/ / | |  ', '/  ___ |  ', '\\/  |_|   '
            ], CharacterType.SPECIAL),
            'H': ASCIICharacter('H', [
                ' _    _ ', '| |  | |', '| |__| |', '|  __  |', '| |  | |', '|_|  |_|'
            ])
        }

    async def get_character(self, char: str) -> Optional[ASCIICharacter]:
        return self._character_map.get(char)

class ASCIIArtRenderer:
    def __init__(self, matrix: ASCIIArtMatrix, config: ASCIIConfig):
        self.matrix = matrix
        self.config = config
        self._render_count = 0
        self._last_render_time = None

    async def render_line(self, row_idx: int, message: str) -> str:
        chars = await asyncio.gather(
            *[self.matrix.get_character(char) for char in message]
        )
        return reduce(
            lambda acc, char: acc + (char.matrix[row_idx] if char else " " * self.config.default_width) + self.config.spacing,
            chars,
            ""
        )

    async def render_message(self, message: str) -> None:
        self._render_count += 1
        self._last_render_time = datetime.now()
        
        try:
            for row_idx in range(self.config.rows):
                line = await self.render_line(row_idx, message)
                print(line)
        except Exception as e:
            logger.error(f"Error rendering message: {str(e)}")
            raise

async def main():
    config = ASCIIConfig()
    matrix = ASCIIArtMatrix()
    renderer = ASCIIArtRenderer(matrix, config)
    
    message = "PSBLAH"
    await renderer.render_message(message)

if __name__ == '__main__':
    asyncio.run(main())

Popular repositories Loading

  1. smartplayer smartplayer Public

    smartplayer

  2. CryptoCurrencyTrader CryptoCurrencyTrader Public

    Forked from johndpope/CryptoCurrencyTrader

    A machine learning program in python to generate cryptocurrency trading strategies using machine and deep learning on price, hash rate and scraped forum sentiment data (using natural language proce…

    Python

  3. Temp-Monitor Temp-Monitor Public

    Forked from ssimunic/Temp-Monitor

    Internet of Things data platform for temperature and humidity sensors with maps

    PHP

  4. rpi-security-system rpi-security-system Public

    Forked from ian-whitestone/rpi-security-system

    Building a home security system with a raspberry pi + Python + Slack

    Python

  5. helm-charts helm-charts Public

    Forked from codecentric/helm-charts

    A curated set of Helm charts brought to you by codecentric

    HTML

  6. psblah psblah Public

    Python