Terminal Pattern Generator

January 27, 2026

#typescript#ascii#art#terminal#patterns

ASCII art pattern generator that creates noise, wave, and circuit patterns. Built with TypeScript and configurable parameters.

Terminal Pattern Generator

A TypeScript class that generates ASCII art patterns with configurable parameters. Creates three different pattern types: noise, wave, and circuit patterns.

Features

  • Noise Pattern: Random distribution of characters with configurable density
  • Wave Pattern: Sine wave-based patterns with varying intensity
  • Circuit Pattern: Terminal-style circuit board aesthetics

Example Output

Noise Pattern

``` ▒ ▓▓░ ░ █▓▓█ ░░ ▓ ▒▓ █ ▒▒▓ ▒▓ ▓ █ █ ░░ █ █ ▓▓░▒ ░ █ ▓ ▒▒ ▓
█ █ █ ░ █ ▓ ░▓ ░ ░░ ▒█ ▓ ▓ ▒▓ ▓▓ █░ █ ░ ▓ ░ ▓█ █▓ ░ ░░░ ▒░
```

Wave Pattern

``` ▓▓██████████▓▓▓ ▓▓██████████▓▓▓
▓██████████▓▓ ▓▓██████████▓▓▓ ▓ █████████▓▓▓ ▓▓▓██████████▓▓▓ ▓▓█ ███████▓▓▓ ▓▓██████████▓▓▓ ▓▓███ ```

Circuit Pattern

``` ── ─ ┘│ ─│ ┤ │ ─ ┴ ┐ └ ── ┬ ─ ┼
├ ─ ┐ ┴ └ ┴ ┼ ┬
── ─ │ ├ ┴ ─ ─ ─ ─ │ ─ ┤ ─ ┘ ─ ─└ ─
┐ ├│ │ │ │ ├ ┴ │
```

Usage

```typescript const generator = new TerminalPatternGenerator(42); // Optional seed

// Generate noise pattern const noise = generator.generate({ width: 60, height: 15, chars: ['▓', '▒', '░', '█'], density: 0.3 });

// Generate wave pattern const wave = generator.generateWave({ width: 60, height: 15, chars: ['░', '▒', '▓', '█'], density: 0.5 });

// Generate circuit pattern const circuit = generator.generateCircuit({ width: 60, height: 15, chars: [], density: 0.3 }); ```

TypeScript Code

```typescript interface PatternConfig { width: number; height: number; chars: string[]; density: number; seed?: number; }

class TerminalPatternGenerator { private rng: () => number;

constructor(seed?: number) { // Simple seeded random number generator let s = seed || Math.floor(Math.random() * 1000000); this.rng = () => { s = Math.sin(s) * 10000; return s - Math.floor(s); }; }

generate(config: PatternConfig): string { const { width, height, chars, density } = config; const lines: string[] = [];

for (let y = 0; y < height; y++) {
  let line = '';
  for (let x = 0; x < width; x++) {
    if (this.rng() < density) {
      const charIndex = Math.floor(this.rng() * chars.length);
      line += chars[charIndex];
    } else {
      line += ' ';
    }
  }
  lines.push(line);
}

return lines.join('\n');

}

generateWave(config: PatternConfig): string { const { width, height, chars } = config; const lines: string[] = [];

for (let y = 0; y < height; y++) {
  let line = '';
  for (let x = 0; x < width; x++) {
    const wave = Math.sin((x / width) * Math.PI * 4 + (y / height) * Math.PI * 2);
    const intensity = (wave + 1) / 2; // normalize to 0-1

    if (intensity > 0.5) {
      const charIndex = Math.floor(intensity * chars.length);
      line += chars[Math.min(charIndex, chars.length - 1)];
    } else {
      line += ' ';
    }
  }
  lines.push(line);
}

return lines.join('\n');

}

generateCircuit(config: PatternConfig): string { const { width, height } = config; const lines: string[] = []; const circuits = ['─', '│', '┌', '┐', '└', '┘', '├', '┤', '┬', '┴', '┼'];

for (let y = 0; y < height; y++) {
  let line = '';
  for (let x = 0; x < width; x++) {
    // Create circuit-like patterns based on position
    const isNode = (x + y) % 3 === 0;
    const isHorizontal = y % 2 === 0;
    const isVertical = x % 3 === 1;

    if (isNode && this.rng() > 0.7) {
      line += circuits[Math.floor(this.rng() * circuits.length)];
    } else if (isHorizontal && this.rng() > 0.8) {
      line += '─';
    } else if (isVertical && this.rng() > 0.8) {
      line += '│';
    } else {
      line += ' ';
    }
  }
  lines.push(line);
}

return lines.join('\n');

} }

export { TerminalPatternGenerator, type PatternConfig }; ```

Implementation Notes

Uses a simple seeded random number generator for reproducible patterns. The wave pattern applies sine functions across both x and y axes to create flowing patterns. Circuit patterns use modular arithmetic to create grid-like structures with ASCII box-drawing characters.