ascii-heart

2.0.0 • Public • Published

ascii-heart Version Downloads

Create ASCII hearts using Node.js.

Installation

$ npm i --save ascii-heart

Example

var asciiHeart = require("ascii-heart");
 
// Default behavior
console.log(asciiHeart());
// =>
//                    * * * * * *                   * * * * * *
//                * * *         * * *           * * *         * * *
//            * * *                 * *       * *                 * * *
//            *                       * *   * *                       *
//          *                           *   *                           *
//        * *                           * * *                           * *
//        *                               *                               *
//        *                               *                               *
//        *                                                               *
//        *                                                               *
//        *                                                               *
//        * *                                                           * *
//          *                                                           *
//          * *                                                       * *
//            * *                                                   * *
//              * *                                               * *
//                * *                                           * *
//                  * *                                       * *
//                    * *                                   * *
//                      * *                               * *
//                        * *                           * *
//                          * *                       * *
//                            * *                   * *
//                              * *               * *
//                                * *           * *
//                                  * *       * *
//                                    * *   * *
//                                      * * *
//                                        *
//                                        *
 
// Display a small heart (width x height) <3
console.log(asciiHeart(10, 10));
// =>
//     * * *   * * *
//   * *   * * *   * *
//   *       *       *
//   * *           * *
//     * *       * *
//       * *   * *
//         * * *
//           *
 
// Display a small heart,
console.log(asciiHeart(40, 40, {
    fill: ""
}));
// =>
//                    * * * * * *                   * * * * * *
//                * * * ❤ ❤ ❤ ❤ * * *           * * * ❤ ❤ ❤ ❤ * * *
//            * * * ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ * *       * * ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ * * *
//            * ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ * *   * * ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ *
//          * ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ *   * ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ *
//        * * ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ * * * ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ * *
//        * ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ * ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ *
//        * ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ * ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ *
//        * ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ *
//        * ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ *
//        * ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ *
//        * * ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ * *
//          * ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ *
//          * * ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ * *
//            * * ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ * *
//              * * ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ * *
//                * * ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ * *
//                  * * ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ * *
//                    * * ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ * *
//                      * * ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ * *
//                        * * ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ * *
//                          * * ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ * *
//                            * * ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ ❤ * *
//                              * * ❤ ❤ ❤ ❤ ❤ ❤ ❤ * *
//                                * * ❤ ❤ ❤ ❤ ❤ * *
//                                  * * ❤ ❤ ❤ * *
//                                    * * ❤ * *
//                                      * * *
//                                        *
//                                        *

Documentation

asciiHeart(width, height, options)

Generates a beautiful heart in ASCII art. 💖

Params

  • Number width: The heart width (default: 40).
  • Number height: The heart height (default: 40).
  • Object options: An object containing the following fields:
  • fill (String): The character used to fill the heart (default: " ").
  • trim (Boolean): If false, the trailing spaces on the right side will not be removed (default: true).
  • k (Number): A magic number used in the graph generating (default: 100).
  • step (Number): The step precision (default: 0.01).

Return

  • String The stringified heart.

How to contribute

Have an idea? Found a bug? See how to contribute.

Where is this library used?

If you are using this library in one of your projects, add it in this list. ✨

License

MIT © Nuvi Pannu

Readme

Keywords

Package Sidebar

Install

npm i ascii-heart

Weekly Downloads

3

Version

2.0.0

License

MIT

Last publish

Collaborators

  • ionicabizau
  • nuvipannu