🔍 Code Extractor

class EInkStyler

Maturity: 45

A utility class providing styling configurations and color palettes optimized for e-ink displays with high contrast and minimal grayscale variations.

File:
/tf/active/vicechatdev/e-ink-llm/graphics_generator.py
Lines:
45 - 82
Complexity:
simple

Purpose

EInkStyler provides predefined color schemes, font sizes, and matplotlib style configurations specifically designed for e-ink displays. It offers high-contrast color palettes and chart styling that work well with the limited color range and refresh characteristics of e-ink screens. The class is designed as a configuration container with static methods and class-level constants, requiring no instantiation for normal use.

Source Code

class EInkStyler:
    """Styling configuration optimized for e-ink displays"""
    
    # E-ink optimized color palette (high contrast)
    COLORS = {
        'black': '#000000',
        'white': '#FFFFFF', 
        'gray_dark': '#333333',
        'gray_medium': '#666666',
        'gray_light': '#CCCCCC'
    }
    
    # Chart colors for e-ink (using patterns/shades)
    CHART_COLORS = ['#000000', '#333333', '#666666', '#999999', '#CCCCCC']
    
    # Font settings
    FONT_SIZES = {
        'title': 14,
        'subtitle': 12,
        'body': 10,
        'caption': 8
    }
    
    @staticmethod
    def get_eink_style():
        """Get matplotlib style configuration for e-ink displays"""
        return {
            'figure.facecolor': 'white',
            'axes.facecolor': 'white',
            'axes.edgecolor': 'black',
            'axes.linewidth': 1.0,
            'grid.color': '#CCCCCC',
            'grid.linewidth': 0.5,
            'text.color': 'black',
            'axes.labelcolor': 'black',
            'xtick.color': 'black',
            'ytick.color': 'black'
        }

Parameters

Name Type Default Kind
bases - -

Parameter Details

bases: This parameter appears in the docstring but is not used in the class definition. The class has no __init__ method and is not designed to be instantiated. All functionality is provided through class attributes and static methods.

Return Value

The class itself returns nothing when referenced. The static method get_eink_style() returns a dictionary containing matplotlib style configuration parameters optimized for e-ink displays, with keys like 'figure.facecolor', 'axes.facecolor', etc., and their corresponding color/size values.

Class Interface

Methods

get_eink_style() -> dict static

Purpose: Returns a dictionary of matplotlib style parameters optimized for e-ink displays

Returns: Dictionary with matplotlib rcParams keys and values for e-ink display optimization, including figure colors, axes properties, grid settings, and text colors

Attributes

Name Type Description Scope
COLORS Dict[str, str] High-contrast color palette with named colors (black, white, gray_dark, gray_medium, gray_light) mapped to hex color codes class
CHART_COLORS List[str] List of five grayscale hex color codes ordered from darkest to lightest, suitable for multi-series charts on e-ink displays class
FONT_SIZES Dict[str, int] Font size mappings for different text elements (title, subtitle, body, caption) optimized for e-ink readability class

Dependencies

  • matplotlib

Required Imports

import matplotlib.pyplot as plt

Usage Example

# Access color palette
black_color = EInkStyler.COLORS['black']
gray_color = EInkStyler.COLORS['gray_medium']

# Get chart colors for plotting
chart_colors = EInkStyler.CHART_COLORS

# Access font sizes
title_size = EInkStyler.FONT_SIZES['title']
body_size = EInkStyler.FONT_SIZES['body']

# Apply e-ink style to matplotlib
import matplotlib.pyplot as plt
eink_style = EInkStyler.get_eink_style()
plt.rcParams.update(eink_style)

# Create a plot with e-ink styling
fig, ax = plt.subplots()
ax.plot([1, 2, 3], [1, 4, 9], color=EInkStyler.COLORS['black'])
ax.set_title('E-ink Optimized Plot', fontsize=EInkStyler.FONT_SIZES['title'])
plt.show()

Best Practices

  • This class is designed as a static utility and does not need to be instantiated. Access all attributes and methods directly via the class name (e.g., EInkStyler.COLORS).
  • Use the COLORS dictionary for consistent color application across e-ink visualizations to maintain high contrast.
  • Apply get_eink_style() to matplotlib's rcParams before creating plots to ensure all charts are e-ink optimized.
  • The CHART_COLORS list provides grayscale values in order from darkest to lightest, useful for multi-series charts on e-ink displays.
  • Font sizes are calibrated for typical e-ink display resolutions; adjust if targeting specific screen sizes.
  • The class maintains no state and has no side effects, making it safe to use across multiple threads or processes.
  • All colors use hex format for compatibility with matplotlib and other visualization libraries.

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class ChartGenerator 59.7% similar

    A class that generates various types of charts (bar, line, pie, scatter) optimized for e-ink displays with high contrast and clear visibility.

    From: /tf/active/vicechatdev/e-ink-llm/graphics_generator.py
  • class PDFGenerator 52.7% similar

    A class that generates PDF documents optimized for e-ink displays, converting LLM responses and images into formatted, high-contrast PDFs with custom styling.

    From: /tf/active/vicechatdev/e-ink-llm/pdf_generator.py
  • class CompactResponseFormatter 48.6% similar

    A formatter class that converts verbose LLM responses into compact, symbol-rich text optimized for e-ink displays by using Unicode symbols, mathematical notation, and abbreviated formatting.

    From: /tf/active/vicechatdev/e-ink-llm/compact_formatter.py
  • function demo_graphics_generation 47.1% similar

    Demonstrates the generation of three types of graphics (bar chart, process diagram, and mathematical illustration) using the GraphicsGenerator class with e-ink optimized styling.

    From: /tf/active/vicechatdev/e-ink-llm/demo_hybrid_mode.py
  • function main_v59 46.7% similar

    Orchestrates a comprehensive demonstration of E-Ink LLM hybrid mode capabilities, running three sequential demos showcasing graphics generation, placeholder parsing, and complete hybrid response processing.

    From: /tf/active/vicechatdev/e-ink-llm/demo_hybrid_mode.py
← Back to Browse