/asciiart-logo

Logo for Node application with ASCII Art

Primary LanguageJavaScriptThe UnlicenseUnlicense

ASCII-art Logo

asciiart-logo renders a splash screen in text console with logo from ASCII characters.

Splash screen is a rectangular panel and logo is the application name rendered by ASCII-art fonts extended by optional additional information (author, application version, short desctiption, etc). Example console output from this project's package.json:

,-------------------------------------------------------------------.
|                                                                   |
|       _             _ _            _     _                        |
|      / \   ___  ___(_|_) __ _ _ __| |_  | |    ___   __ _  ___    |
|     / _ \ / __|/ __| | |/ _` | '__| __| | |   / _ \ / _` |/ _ \   |
|    / ___ \\__ \ (__| | | (_| | |  | |_  | |__| (_) | (_| | (_) |  |
|   /_/   \_\___/\___|_|_|\__,_|_|   \__| |_____\___/ \__, |\___/   |
|                                                     |___/         |
|                                                                   |
|                                                    version 0.2.3  |
|                                                                   |
|  Splashscreen with logo from ASCII characters in text console.    |
|                                                                   |
`-------------------------------------------------------------------'

asciiart-logo can be used by starting of command line tools, web servers or REST API microservices as a visual feedback to the user or administrator about successful start of the application.

Quick Start

  1. Download and install with command npm install asciiart-logo
  2. See in action with command node example.js

Simple Usage: Default Splash Screen

Simplest usage is to provide the package.json file and call the method render to write out the splash screen to console:

const logo = require('asciiart-logo');
const config = require('./package.json');
console.log(logo(config).render());

The asciiart-logo will render following information from the package.json:

  • name - rendered with ASCII-art font to dominate the splash screen
  • version - right-alligned so it will not "fight" for reader's attention
  • description - short information about the project

## Rich Usage: Explicit Parametrization

The main impression of the splash screen is shaped by the selection of the right ASCII-art font.

Number of characters of the logo in single line (parameter lineChars) controls word wrapping logic in logo rendering and indirectly the width of the panel.

You can adjust also padding and margin of the panel.

  • name - applicaiton name in ascii-art logo (name parameter in project.json defines name of the application)
  • font - ASCII-art font from the font gallery - default font is Standard
  • lineChars - length of line in name (ascii-art logo) for word wrapping
  • padding - space around the panel around text (like in CSS) - default is 5
  • margin - left space outside of the panel - default is 2

Text functions

The text in splash screen is wrapped according the size of logo. Spaces, new lines, tabs are squeezed into single space. Text can be programmatically writen with functions:

  • left - text is alligned to left or wrapped
  • right - text is alligned to right or wrapped
  • center - text is alligned to center or wrapped
  • wrap - synonym to function left
  • emptyLine - add empty line into the panel

Method render() must be the last one to call - it writes out the splash screen to console.

Color

Default usage prints the splash screen with default color. Splash screen can be colored by parameters:

  • logoColor
  • textColor
  • borderColor

Color can have following values:

  • black, red, green, blue, yellow, magenta, cyan, white
  • bold-black, bold-red, bold-green, bold-blue, bold-yellow, bold-magenta, bold-cyan, bold-white

Example with parametrization and text functions

const longText = 'Lorem ipsum dolor sit amet, ' +
    'consectetur adipiscing elit, ' +
    'sed do eiusmod tempor incididunt ut labore et ' +
    'dolore magna aliqua. Ut enim ad minim veniam, ' +
    'quis nostrud exercitation ullamco laboris ' +
    'nisi ut aliquip ex ea commodo consequat. Duis aute ' +
    'irure dolor in reprehenderit in voluptate velit esse ' +
    'cillum dolore eu fugiat nulla pariatur. ' +
    'Excepteur sint occaecat cupidatat non proident, ' +
    'sunt in culpa qui officia deserunt mollit anim ' +
    'id est laborum.';

console.log(
    logo({
        name: 'Just a simple example',
        font: 'Speed',
        lineChars: 10,
        padding: 2,
        margin: 3,
        borderColor: 'grey',
        logoColor: 'bold-green',
        textColor: 'green',
    })
    .emptyLine()
    .right('version 3.7.123')
    .emptyLine()
    .center(longText)
    .render()
);

... and the output on the console:

   ,---------------------------------------------------------.
   |                                                         |
   |  _________             _____                            |
   |  ______  /___  __________  /_   ______ _                |
   |  ___ _  /_  / / /_  ___/  __/   _  __ `/                |
   |  / /_/ / / /_/ /_(__  )/ /_     / /_/ /                 |
   |  \____/  \__,_/ /____/ \__/     \__,_/                  |
   |                                                         |
   |  ____________                   ______                  |
   |  __  ___/__(_)______ ______________  /____              |
   |  _____ \__  /__  __ `__ \__  __ \_  /_  _ \             |
   |  ____/ /_  / _  / / / / /_  /_/ /  / /  __/             |
   |  /____/ /_/  /_/ /_/ /_/_  .___//_/  \___/              |
   |                         /_/                             |
   |  __________                                ______       |
   |  ___  ____/___  _______ _______ ______________  /____   |
   |  __  __/  __  |/_/  __ `/_  __ `__ \__  __ \_  /_  _ \  |
   |  _  /___  __>  < / /_/ /_  / / / / /_  /_/ /  / /  __/  |
   |  /_____/  /_/|_| \__,_/ /_/ /_/ /_/_  .___//_/  \___/   |
   |                                    /_/                  |
   |                                                         |
   |                                        version 3.7.123  |
   |                                                         |
   |   Lorem ipsum dolor sit amet, consectetur adipiscing    |
   |   elit, sed do eiusmod tempor incididunt ut labore et   |
   |   dolore magna aliqua. Ut enim ad minim veniam, quis    |
   |  nostrud exercitation ullamco laboris nisi ut aliquip   |
   |    ex ea commodo consequat. Duis aute irure dolor in    |
   |   reprehenderit in voluptate velit esse cillum dolore   |
   |    eu fugiat nulla pariatur. Excepteur sint occaecat    |
   |    cupidatat non proident, sunt in culpa qui officia    |
   |          deserunt mollit anim id est laborum.           |
   |                                                         |
   `---------------------------------------------------------'

Credits

The asciiart-logo uses following awsome libraries:

  • ASCII-art font Font rendering: fiddler
  • Color: chalk
  • Text in title case: to-title-case