forked from genewildish/Mainline
Major changes: - Pipeline architecture with capability-based dependency resolution - Effects plugin system with performance monitoring - Display abstraction with multiple backends (terminal, null, websocket) - Camera system for viewport scrolling - Sensor framework for real-time input - Command-and-control system via ntfy - WebSocket display backend for browser clients - Comprehensive test suite and documentation Issue #48: ADR for preset scripting language included This commit consolidates 110 individual commits into a single feature integration that can be reviewed and tested before further refinement.
61 lines
2.0 KiB
Python
61 lines
2.0 KiB
Python
"""Checkerboard data source for visual pattern generation."""
|
|
|
|
from engine.data_sources.sources import DataSource, SourceItem
|
|
|
|
|
|
class CheckerboardDataSource(DataSource):
|
|
"""Data source that generates a checkerboard pattern.
|
|
|
|
Creates a grid of alternating characters, useful for testing motion effects
|
|
and camera movement. The pattern is static; movement comes from camera panning.
|
|
"""
|
|
|
|
def __init__(
|
|
self,
|
|
width: int = 200,
|
|
height: int = 200,
|
|
square_size: int = 10,
|
|
char_a: str = "#",
|
|
char_b: str = " ",
|
|
):
|
|
"""Initialize checkerboard data source.
|
|
|
|
Args:
|
|
width: Total pattern width in characters
|
|
height: Total pattern height in lines
|
|
square_size: Size of each checker square in characters
|
|
char_a: Character for "filled" squares (default: '#')
|
|
char_b: Character for "empty" squares (default: ' ')
|
|
"""
|
|
self.width = width
|
|
self.height = height
|
|
self.square_size = square_size
|
|
self.char_a = char_a
|
|
self.char_b = char_b
|
|
|
|
@property
|
|
def name(self) -> str:
|
|
return "checkerboard"
|
|
|
|
@property
|
|
def is_dynamic(self) -> bool:
|
|
return False
|
|
|
|
def fetch(self) -> list[SourceItem]:
|
|
"""Generate the checkerboard pattern as a single SourceItem."""
|
|
lines = []
|
|
for y in range(self.height):
|
|
line_chars = []
|
|
for x in range(self.width):
|
|
# Determine which square this position belongs to
|
|
square_x = x // self.square_size
|
|
square_y = y // self.square_size
|
|
# Alternate pattern based on parity of square coordinates
|
|
if (square_x + square_y) % 2 == 0:
|
|
line_chars.append(self.char_a)
|
|
else:
|
|
line_chars.append(self.char_b)
|
|
lines.append("".join(line_chars))
|
|
content = "\n".join(lines)
|
|
return [SourceItem(content=content, source="checkerboard", timestamp="0")]
|