oh-my-logo

repository·main·Indexed 23 days ago

https://github.com/shinshin86/oh-my-logo

A tool for creating ASCII art and filled block character logos with colorful gradients for terminal use. Available as a CLI tool and a Node.js library, it features functions like render() for standard ASCII art and renderFilled() for solid block characters with customizable shadow styles (block, chrome, shade, simpleBlock). It supports built-in and custom color palettes, multiple Figlet fonts, and gradient directions (vertical, horizontal, diagonal). Version 0.5.0.

Tokens
7.2K
Snippets
31
Records
48
Agent score
81%

What's inside oh-my-logo

  1. Add new color palettes

    main

    To add a custom palette, edit src/palettes.ts and add your color combinations to the PALETTES object. Use hex color strings.

    export const PALETTES = {
      // ... existing palettes
      'my-palette': ['#ff0000', '#00ff00', '#0000ff'],
    } as const;
  2. Install Deno

    main

    The examples are designed to be run using the Deno runtime. Use the following commands based on your operating system:

    macOS/Linux

    curl -fsSL https://deno.land/install.sh | sh

    Windows

    irm https://deno.land/install.ps1 | iex

    Package Managers

    • macOS: brew install deno
    • Windows: choco install deno
    # macOS/Linux
    curl -fsSL https://deno.land/install.sh | sh
    
    # Windows
    irm https://deno.land/install.ps1 | iex
  3. Run the test suite

    main

    The project uses Vitest for testing. Use the following commands to run different test scenarios:

    • npm run test: Run all tests in watch mode.
    • npm run test:coverage: Run tests once (CI mode).
    • npm run test:ui: Run tests with a UI.
    • npm test -- <path>: Run a specific test file (e.g., npm test -- src/__tests__/cli.test.ts).
    npm run test
    npm run test:coverage
    npm run test:ui
    npm test -- src/__tests__/cli.test.ts
  4. Run the project in development mode

    main

    To contribute or test changes locally, you can use the following commands after installing dependencies:

    # Install dependencies
    npm install
    
    # Run in development mode with specific arguments
    npm run dev -- "TEST" sunset --filled
    
    # Build the project
    npm run build
    
    # Test the built version
    node dist/index.js "HELLO" matrix --filled
    npm install
    npm run dev -- "TEST" sunset --filled
    npm run build
    node dist/index.js "HELLO" matrix --filled
  5. Add a new custom palette

    main

    To add a new color combination, edit src/palettes.ts and add your palette to the PALETTES object:

    export const PALETTES = {
      // ... existing palettes
      'my-palette': ['#ff0000', '#00ff00', '#0000ff'],
    } as const;
    export const PALETTES = {
      'my-palette': ['#ff0000', '#00ff00', '#0000ff'],
    } as const;
  6. Install oh-my-logo

    main

    You can use oh-my-logo as a CLI tool or as a library in your applications.

    CLI Installation

    Install globally to use the oh-my-logo command anywhere:

    npm install -g oh-my-logo

    Library Installation

    Install as a dependency in your project:

    npm install oh-my-logo
    npm install -g oh-my-logo
    # or
    npm install oh-my-logo
  7. Quick Start with oh-my-logo CLI

    main

    The fastest way to generate an ASCII logo is using npx.

    Basic ASCII Art Logo:

    npx oh-my-logo "HELLO WORLD"

    Filled Block Character Logo: Use the --filled flag to switch from outline ASCII to solid block characters.

    npx oh-my-logo "YOUR LOGO" sunset --filled
    npx oh-my-logo "HELLO WORLD"
    npx oh-my-logo "YOUR LOGO" sunset --filled
  8. Verify terminal stability for filled mode

    main

    If you are modifying the Ink renderer or testing terminal compatibility, use the provided stress test script to ensure --filled mode correctly cleans up terminal states and doesn't cause corruption.

    ./scripts/test-filled-mode.sh
  9. Use oh-my-logo as a JavaScript/TypeScript library

    main

    You can import functions to programmatically generate logos for animations or terminal applications.

    Basic ASCII Rendering

    Use render for standard outline ASCII art.

    import { render } from 'oh-my-logo';
    
    const logo = await render('HELLO WORLD', {
      palette: 'sunset',
      direction: 'horizontal'
    });
    console.log(logo);

    Filled Block Rendering

    Use renderFilled for solid block characters. This supports custom shadow styles via the font option.

    import { renderFilled } from 'oh-my-logo';
    
    // Standard filled
    await renderFilled('AWESOME', { palette: 'fire' });
    
    // Filled with dotted/shaded effect
    await renderFilled('SHADOW', { palette: 'sunset', font: 'shade' });

    Custom Colors and TypeScript

    Pass an array of CSS colors or hex codes to the palette option.

    import { render, RenderOptions, PaletteName } from 'oh-my-logo';
    
    const options: RenderOptions = {
      palette: ['#ff0000', '#00ff00', '#0000ff'],
      direction: 'diagonal',
      font: 'Standard'
    };
    
    const customLogo = await render('MY BRAND', options);
    console.log(customLogo);
    import { render, renderFilled, PALETTES, getPaletteNames } from 'oh-my-logo';
    
    // Basic ASCII art rendering
    const logo = await render('HELLO WORLD', {
      palette: 'sunset',
      direction: 'horizontal'
    });
    console.log(logo);
    
    // Using custom colors
    const customLogo = await render('MY BRAND', {
      palette: ['#ff0000', '#00ff00', '#0000ff'],
      font: 'Big',
      direction: 'diagonal'
    });
    
    // Filled block characters
    await renderFilled('AWESOME', {
      palette: 'fire'
    });
    
    // Using custom shadow styles in filled mode
    await renderFilled('SHADOW', {
      palette: 'sunset',
      font: 'shade'  // Use dotted/shaded effect
    });
  10. How to add new development scripts

    main

    To add new utility scripts to the development environment, follow these steps:

    1. Place the script file in the scripts/ directory.
    2. Ensure the script is executable by running: chmod +x scripts/your-script.sh.
    3. Document the new script in scripts/README.md including its Purpose, Usage instructions, When to use, and Expected behavior.
    chmod +x scripts/your-script.sh
  11. Run oh-my-logo examples with Deno

    main

    Run the example scripts from the project root using deno run. Most examples require --allow-env (to access environment variables) and --allow-read (to read font files). Some may require --allow-write.

    Example TypeCommand
    Basic Usagedeno run --allow-env --allow-read examples/basic.ts
    Advanced Featuresdeno run --allow-env --allow-read examples/advanced.ts
    Filled Charactersdeno run --allow-env --allow-read --allow-write examples/filled.ts
    Error Handlingdeno run --allow-env --allow-read examples/error-handling.ts
    Rainbow Animationdeno run --allow-env --allow-read examples/rainbow.ts $'YOUR\nTEXT'
    # Basic usage examples
    deno run --allow-env --allow-read examples/basic.ts
    
    # Advanced features (gradients, fonts, custom colors)
    deno run --allow-env --allow-read examples/advanced.ts
    
    # Filled character rendering (may need additional permissions)
    deno run --allow-env --allow-read --allow-write examples/filled.ts
    
    # Error handling examples
    deno run --allow-env --allow-read examples/error-handling.ts
    
    # Rainbow animation with cycling colors/fonts and progressive text display
    deno run --allow-env --allow-read examples/rainbow.ts $'YOUR\nTEXT'