Projects STRLCPY cfonts Commits ab0740ba
🤬
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■ ■
    README.md
    skipped 243 lines
    244 244  With this setting you can set a gradient over your output.
    245 245  This setting supersedes the color open.
    246 246  The gradient requires two colors, a start color and an end color from left to right.
     247 +_(If you want to set your own colors for the gradient, use the [transition](#-t---transition-gradient) option.)_
    247 248  CFonts will then generate a gradient through as many colors as it can find to make the output most impressive.
    248 249  Provide two colors in a comma-separated string, eg: `red,blue`. _(no spaces)_
    249 250  If you use a hex color make sure you include the `#` prefix. _(In the terminal wrap the hex in quotes)_
    skipped 23 lines
    273 274  Default value: `false`
    274 275   
    275 276  Set this option to re-calculate the gradient colors for each new line.
     277 +Only works in combination with the [gradient](#-g---gradient) option.
    276 278   
    277 279  ```shell
    278 280  $ cfonts "text|next line" --gradient red,"#f80" --independentGradient
    279 281  ```
    280 282   
    281 283  ![Independent gradient command](https://raw.githubusercontent.com/dominikwilkowski/cfonts/master/img/independent-gradient.png)
     284 + 
     285 + 
     286 +#### -t, --transition-gradient
     287 +Type: `<boolean>`
     288 +Default value: `false`
     289 + 
     290 +Set this option to generate your own gradients.
     291 +Each color set in the gradient option will then be transitioned to directly.
     292 +This option allows you to specify more than just two colors for your gradient.
     293 +Only works in combination with the [gradient](#-g---gradient) option.
     294 + 
     295 +```shell
     296 +$ cfonts "text" --gradient red,"#f80",green,blue --transition-gradient
     297 +```
     298 + 
     299 +![Independent gradient command](https://raw.githubusercontent.com/dominikwilkowski/cfonts/master/img/transition-gradient.png)
    282 300   
    283 301   
    284 302  #### -b, --background
    skipped 139 lines
    424 442   
    425 443   
    426 444  ## Release History
     445 +* 2.6.0 - added transition gradients and sets
    427 446  * 2.5.2 - fixed jsDocs, added typescript type test
    428 447  * 2.5.1 - fixed array output to include everything including colors
    429 448  * 2.5.0 - added gradient option, separated code into files, added 100% unit testing coverage
    skipped 47 lines
  • img/transition-gradient.png
  • ■ ■ ■ ■
    package.json
    1 1  {
    2 2   "name": "cfonts",
    3 3   "description": "Sexy fonts for the console",
    4  - "version": "2.5.2",
     4 + "version": "2.6.0",
    5 5   "homepage": "https://github.com/dominikwilkowski/cfonts",
    6 6   "author": {
    7 7   "name": "Dominik Wilkowski",
    skipped 100 lines
  • ■ ■ ■ ■ ■ ■
    src/CheckInput.js
    skipped 20 lines
    21 21   COLORS,
    22 22   BGCOLORS,
    23 23   GRADIENTCOLORS,
     24 + GRADIENTS,
    24 25   ALIGNMENT,
    25 26   FONTFACES,
    26 27   HEXTEST,
    skipped 13 lines
    40 41   * @param {object} fontfaces - All allowed fontfaces
    41 42   * @param {object} colors - All allowed font colors
    42 43   * @param {object} bgcolors - All allowed background colors
     44 + * @param {object} gradientcolors - All allowed gradient colors
     45 + * @param {object} gradients - All allowed gradients
    43 46   * @param {array} alignment - All allowed alignments
    44 47   *
    45 48   * @typedef {object} ReturnObject
    skipped 14 lines
    60 63   colors = COLORS,
    61 64   bgcolors = BGCOLORS,
    62 65   gradientcolors = GRADIENTCOLORS,
     66 + gradients = GRADIENTS,
    63 67   alignment = ALIGNMENT
    64 68  ) => {
    65 69   let result = {
    skipped 61 lines
    127 131   
    128 132   // CHECKING GRADIENT
    129 133   if( userGradient ) {
    130  - if( userGradient.length < 2 ) {
    131  - return {
    132  - message: `"${ Chalk.red( userGradient ) }" is not a valid gradient option.\n` +
    133  - `Please pass in${ userTransitionGradient ? ' at least' : '' } two colors.`,
    134  - pass: false,
    135  - };
     134 + if(
     135 + userGradient.length === 1
     136 + && Object.keys( gradients ).indexOf( userGradient[ 0 ].toLowerCase() ) !== -1
     137 + && userTransitionGradient
     138 + ) {
     139 + return result;
    136 140   }
     141 + else {
     142 + if( userGradient.length < 2 ) {
     143 + return {
     144 + message: `"${ Chalk.red( userGradient ) }" is not a valid gradient option.\n` +
     145 + `Please pass in${ userTransitionGradient ? ' at least' : '' } two colors.`,
     146 + pass: false,
     147 + };
     148 + }
    137 149   
    138  - if( userGradient.length !== 2 && !userTransitionGradient ) {
    139  - return {
    140  - message: `"${ Chalk.red( userGradient ) }" is not a valid gradient option.\n` +
    141  - `Please pass in two colors.`,
    142  - pass: false,
    143  - };
    144  - }
    145  - 
    146  - // check validity of colors
    147  - userGradient.forEach( color => {
    148  - if(
    149  - Object.keys( gradientcolors ).indexOf( color.toLowerCase() ) === -1
    150  - && !HEXTEST.test( color )
    151  - ) {
    152  - result = {
    153  - message: `"${ Chalk.red( color ) }" is not a valid gradient color option.\n` +
    154  - `Please use a color from the supported stack or any valid hex color:\n${ Chalk.green(`${
    155  - Object.keys( gradientcolors ).map( color => colors[ color ] ).join(', ')
    156  - }, "#3456ff", "#f80", etc...`) }`,
     150 + if( userGradient.length !== 2 && !userTransitionGradient ) {
     151 + return {
     152 + message: `"${ Chalk.red( userGradient ) }" is not a valid gradient option.\n` +
     153 + `Please pass in two colors.`,
    157 154   pass: false,
    158 155   };
    159 156   }
    160  - });
     157 + 
     158 + // check validity of colors
     159 + userGradient.forEach( color => {
     160 + if(
     161 + Object.keys( gradientcolors ).indexOf( color.toLowerCase() ) === -1
     162 + && !HEXTEST.test( color )
     163 + ) {
     164 + result = {
     165 + message: `"${ Chalk.red( color ) }" is not a valid gradient color option.\n` +
     166 + `Please use a color from the supported stack or any valid hex color:\n${ Chalk.green(`${
     167 + Object.keys( gradientcolors ).map( color => colors[ color ] ).join(', ')
     168 + }, "#3456ff", "#f80", etc...`) }`,
     169 + pass: false,
     170 + };
     171 + }
     172 + });
     173 + }
    161 174   }
    162 175   
    163 176   return result;
    skipped 7 lines
  • ■ ■ ■ ■ ■ ■
    src/Gradient.js
    skipped 17 lines
    18 18   
    19 19  const { GetFirstCharacterPosition } = require('./GetFirstCharacterPosition.js');
    20 20  const { GetLongestLine } = require('./GetLongestLine.js');
     21 +const { GRADIENTS } = require('./constants.js');
    21 22  const { Debugging } = require('./Debugging.js');
    22 23  const { Color } = require('./Color.js');
    23 24   
    skipped 391 lines
    415 416  /**
    416 417   * Generate n colors between x colors
    417 418   *
    418  - * @param {array} colors - An array of colors in hex
    419  - * @param {number} steps - The amount of colors to generate
     419 + * @param {array} colors - An array of colors in hex
     420 + * @param {number} steps - The amount of colors to generate
     421 + * @param {object} gradients - An object of pre-packaged gradient colors
    420 422   *
    421  - * @return {array} - An array of colors
     423 + * @return {array} - An array of colors
    422 424   */
    423  -function Transition( colors, steps ) {
    424  - const gaps = GetGaps( colors, steps );
     425 +function Transition( colors, steps, gradients = GRADIENTS ) {
    425 426   let hexColors = [];
    426  - colors = colors.map( color => Color2hex( color ) );
     427 + if( colors.length === 1 ) {
     428 + colors = gradients[ colors[ 0 ].toLowerCase() ];
     429 + }
     430 + else {
     431 + colors = colors.map( color => Color2hex( color ) );
     432 + }
     433 + const gaps = GetGaps( colors, steps );
    427 434   
    428 435   if( steps <= 1 ) {
    429 436   return [ colors[ colors.length - 1 ] ];
    skipped 100 lines
  • ■ ■ ■ ■ ■ ■
    src/constants.js
    skipped 85 lines
    86 86   white: 'white',
    87 87  };
    88 88   
     89 +const GRADIENTS = {
     90 + lgbt: [ '#750787', '#004dff', '#008026', '#ffed00', '#ff8c00', '#e40303' ],
     91 + lgbtq: [ '#750787', '#004dff', '#008026', '#ffed00', '#ff8c00', '#e40303' ],
     92 + pride: [ '#750787', '#004dff', '#008026', '#ffed00', '#ff8c00', '#e40303' ],
     93 + agender: [ '#000000', '#b9b9b9', '#ffffff', '#b8f483', '#ffffff', '#b9b9b9', '#000000' ],
     94 + aromantic: [ '#3da542', '#a7d379', '#ffffff', '#a9a9a9', '#000000' ],
     95 + asexual: [ '#000000', '#a3a3a3', '#ffffff', '#800080' ],
     96 + bisexual: [ '#d60270', '#d60270', '#9b4f96', '#0038a8', '#0038a8' ],
     97 + genderfluid: [ '#ff75a2', '#ffffff', '#be18d6', '#000000', '#333ebd' ],
     98 + genderqueer: [ '#b57edc', '#ffffff', '#4a8123' ],
     99 + intersex: [ '#ffd800', '#ffd800', '#7902aa', '#ffd800', '#ffd800' ],
     100 + lesbian: [ '#d52d00', '#ff9a56', '#ffffff', '#d362a4', '#a30262' ],
     101 + nonbinary: [ '#fcf434', '#ffffff', '#9c5cd4', '#2c2c2c' ],
     102 + pansexual: [ '#ff218c', '#ffd800', '#21b1ff' ],
     103 + polysexual: [ '#f61cb9', '#07d569', '#1c92f6' ],
     104 + transgender: [ '#5bcefa', '#f5a9b8', '#ffffff', '#f5a9b8', '#5bcefa' ],
     105 +};
     106 + 
    89 107  const ALIGNMENT = [
    90 108   'left',
    91 109   'center',
    skipped 124 lines
    216 234   COLORS,
    217 235   BGCOLORS,
    218 236   GRADIENTCOLORS,
     237 + GRADIENTS,
    219 238   ALIGNMENT,
    220 239   FONTFACES,
    221 240   CLIOPTIONS,
    skipped 4 lines
  • ■ ■ ■ ■ ■ ■
    test/unit/CheckInput.spec.js
    skipped 12 lines
    13 13   const COLORS = { color1: 'color1', color2: 'color2', color3: 'color3' };
    14 14   const BGCOLORS = { bgcolor1: 'bgcolor1', bgcolor2: 'bgcolor2', bgcolor3: 'bgcolor3' };
    15 15   const ALIGNMENT = [ 'left', 'center', 'right' ];
     16 + const GRADIENTS = {
     17 + 'set1': ['color1', 'color2'],
     18 + 'set2': ['color1', 'color2'],
     19 + 'set3': ['color1', 'color2'],
     20 + };
    16 21   
    17  - expect( CheckInput( 'INPUT', 'font1', ['color1'], 'bgcolor1', 'left', ['color1','color2'], false, FONTFACES, COLORS, BGCOLORS, COLORS, ALIGNMENT ).pass ).toEqual( true );
    18  - expect( CheckInput( 'INPUT', 'font2', ['color2', 'candy'], 'bgcolor2', 'center', false, false, FONTFACES, COLORS, BGCOLORS, COLORS, ALIGNMENT ).pass ).toEqual( true );
    19  - expect( CheckInput( 'INPUT', 'font3', ['color3'], 'bgcolor3', 'right', ['#ff8800','color3'], false, FONTFACES, COLORS, BGCOLORS, COLORS, ALIGNMENT ).pass ).toEqual( true );
    20  - expect( CheckInput( 'INPUT', 'font3', ['candy'], 'bgcolor3', 'right', ['color1','#ff8800'], false, FONTFACES, COLORS, BGCOLORS, COLORS, ALIGNMENT ).pass ).toEqual( true );
    21  - expect( CheckInput( 'INPUT', 'font3', ['color1'], 'bgcolor2', 'right', ['color1','#ff8800', 'color1', 'color2', 'color3'], true, FONTFACES, COLORS, BGCOLORS, COLORS, ALIGNMENT ).pass ).toEqual( true );
     22 + expect( CheckInput( 'INPUT', 'font1', ['color1'], 'bgcolor1', 'left', ['color1','color2'], false, FONTFACES, COLORS, BGCOLORS, COLORS, GRADIENTS, ALIGNMENT ).pass ).toEqual( true );
     23 + expect( CheckInput( 'INPUT', 'font2', ['color2', 'candy'], 'bgcolor2', 'center', false, false, FONTFACES, COLORS, BGCOLORS, COLORS, GRADIENTS, ALIGNMENT ).pass ).toEqual( true );
     24 + expect( CheckInput( 'INPUT', 'font3', ['color3'], 'bgcolor3', 'right', ['#ff8800','color3'], false, FONTFACES, COLORS, BGCOLORS, COLORS, GRADIENTS, ALIGNMENT ).pass ).toEqual( true );
     25 + expect( CheckInput( 'INPUT', 'font3', ['candy'], 'bgcolor3', 'right', ['color1','#ff8800'], false, FONTFACES, COLORS, BGCOLORS, COLORS, GRADIENTS, ALIGNMENT ).pass ).toEqual( true );
     26 + expect( CheckInput( 'INPUT', 'font3', ['color1'], 'bgcolor2', 'right', ['color1','#ff8800', 'color1', 'color2', 'color3'], true, FONTFACES, COLORS, BGCOLORS, COLORS, GRADIENTS, ALIGNMENT ).pass ).toEqual( true );
     27 + expect( CheckInput( 'INPUT', 'font3', ['color1'], 'bgcolor2', 'right', ['set1'], true, FONTFACES, COLORS, BGCOLORS, COLORS, GRADIENTS, ALIGNMENT ).pass ).toEqual( true );
    22 28  });
    23 29   
    24 30   
    skipped 2 lines
    27 33   const COLORS = { color1: 'coLOr1', color2: 'coLOr2', color3: 'cOLor3' };
    28 34   const BGCOLORS = { bgcolor1: 'bGCOlor1', bgcolor2: 'bGCOlor2', bgcolor3: 'bGCOlor3' };
    29 35   const ALIGNMENT = [ 'left', 'center', 'right' ];
     36 + const GRADIENTS = {
     37 + 'set1': ['color1', 'color2'],
     38 + 'set2': ['color1', 'color2'],
     39 + 'set3': ['color1', 'color2'],
     40 + };
    30 41   
    31  - expect( CheckInput( 'INPUT', 'font1', ['color1'], 'bgcolor1', 'left', ['color1','color2'], false, FONTFACES, COLORS, BGCOLORS, COLORS, ALIGNMENT ).pass ).toEqual( true );
    32  - expect( CheckInput( 'INPUT', 'font2', ['color2', 'candy'], 'bgcolor2', 'center', false, false, FONTFACES, COLORS, BGCOLORS, COLORS, ALIGNMENT ).pass ).toEqual( true );
    33  - expect( CheckInput( 'INPUT', 'font3', ['color3'], 'bgcolor3', 'right', ['#ff8800','color3'], false, FONTFACES, COLORS, BGCOLORS, COLORS, ALIGNMENT ).pass ).toEqual( true );
    34  - expect( CheckInput( 'INPUT', 'font3', ['candy'], 'bgcolor3', 'right', ['color1','#ff8800'], false, FONTFACES, COLORS, BGCOLORS, COLORS, ALIGNMENT ).pass ).toEqual( true );
     42 + expect( CheckInput( 'INPUT', 'font1', ['color1'], 'bgcolor1', 'left', ['color1','color2'], false, FONTFACES, COLORS, BGCOLORS, COLORS, GRADIENTS, ALIGNMENT ).pass ).toEqual( true );
     43 + expect( CheckInput( 'INPUT', 'font2', ['color2', 'candy'], 'bgcolor2', 'center', false, false, FONTFACES, COLORS, BGCOLORS, COLORS, GRADIENTS, ALIGNMENT ).pass ).toEqual( true );
     44 + expect( CheckInput( 'INPUT', 'font3', ['color3'], 'bgcolor3', 'right', ['#ff8800','color3'], false, FONTFACES, COLORS, BGCOLORS, COLORS, GRADIENTS, ALIGNMENT ).pass ).toEqual( true );
     45 + expect( CheckInput( 'INPUT', 'font3', ['candy'], 'bgcolor3', 'right', ['color1','#ff8800'], false, FONTFACES, COLORS, BGCOLORS, COLORS, GRADIENTS, ALIGNMENT ).pass ).toEqual( true );
     46 + expect( CheckInput( 'INPUT', 'font3', ['candy'], 'bgcolor3', 'right', ['sEt2'], true, FONTFACES, COLORS, BGCOLORS, COLORS, GRADIENTS, ALIGNMENT ).pass ).toEqual( true );
    35 47  });
    36 48   
    37 49   
    skipped 2 lines
    40 52   const COLORS = { color1: 'color1', color2: 'color2', color3: 'color3' };
    41 53   const BGCOLORS = { bgcolor1: 'bgcolor1', bgcolor2: 'bgcolor2', bgcolor3: 'bgcolor3' };
    42 54   const ALIGNMENT = [ 'left', 'center', 'right' ];
     55 + const GRADIENTS = {
     56 + 'set1': ['color1', 'color2'],
     57 + 'set2': ['color1', 'color2'],
     58 + 'set3': ['color1', 'color2'],
     59 + };
    43 60   
    44  - const fail = CheckInput( undefined, 'font1', ['color1'], 'bgcolor1', 'left', ['color1','color2'], false, FONTFACES, COLORS, BGCOLORS, COLORS, ALIGNMENT );
     61 + const fail = CheckInput( undefined, 'font1', ['color1'], 'bgcolor1', 'left', ['color1','color2'], false, FONTFACES, COLORS, BGCOLORS, COLORS, GRADIENTS, ALIGNMENT );
    45 62   expect( fail.pass ).toEqual( false );
    46 63   expect( fail.message.length > 0 ).toEqual( true );
    47 64   
    48  - const fail0 = CheckInput( '', 'font1', ['color1'], 'bgcolor1', 'left', false, false, FONTFACES, COLORS, BGCOLORS, COLORS, ALIGNMENT );
     65 + const fail0 = CheckInput( '', 'font1', ['color1'], 'bgcolor1', 'left', false, false, FONTFACES, COLORS, BGCOLORS, COLORS, GRADIENTS, ALIGNMENT );
    49 66   expect( fail0.pass ).toEqual( false );
    50 67   expect( fail0.message.length > 0 ).toEqual( true );
    51 68   
    52  - const fail1 = CheckInput( 'INPUT', 'notfound', ['color1'], 'bgcolor1', 'left', ['#ff8800','color3'], false, FONTFACES, COLORS, BGCOLORS, COLORS, ALIGNMENT );
     69 + const fail1 = CheckInput( 'INPUT', 'notfound', ['color1'], 'bgcolor1', 'left', ['#ff8800','color3'], false, FONTFACES, COLORS, BGCOLORS, COLORS, GRADIENTS, ALIGNMENT );
    53 70   expect( fail1.pass ).toEqual( false );
    54 71   expect( fail1.message.length > 0 ).toEqual( true );
    55 72   
    56  - const fail2 = CheckInput( 'INPUT', 'font1', ['notfound'], 'bgcolor1', 'left', ['color1','#ff8800'], false, FONTFACES, COLORS, BGCOLORS, COLORS, ALIGNMENT );
     73 + const fail2 = CheckInput( 'INPUT', 'font1', ['notfound'], 'bgcolor1', 'left', ['color1','#ff8800'], false, FONTFACES, COLORS, BGCOLORS, COLORS, GRADIENTS, ALIGNMENT );
    57 74   expect( fail2.pass ).toEqual( false );
    58 75   expect( fail2.message.length > 0 ).toEqual( true );
    59 76   
    60  - const fail3 = CheckInput( 'INPUT', 'font1', ['color1'], 'notfound', 'left', false, false, FONTFACES, COLORS, BGCOLORS, COLORS, ALIGNMENT );
     77 + const fail3 = CheckInput( 'INPUT', 'font1', ['color1'], 'notfound', 'left', false, false, FONTFACES, COLORS, BGCOLORS, COLORS, GRADIENTS, ALIGNMENT );
    61 78   expect( fail3.pass ).toEqual( false );
    62 79   expect( fail3.message.length > 0 ).toEqual( true );
    63 80   
    64  - const fail4 = CheckInput( 'INPUT', 'font1', ['color1'], 'bgcolor1', 'notfound', false, false, FONTFACES, COLORS, BGCOLORS, COLORS, ALIGNMENT );
     81 + const fail4 = CheckInput( 'INPUT', 'font1', ['color1'], 'bgcolor1', 'notfound', false, false, FONTFACES, COLORS, BGCOLORS, COLORS, GRADIENTS, ALIGNMENT );
    65 82   expect( fail4.pass ).toEqual( false );
    66 83   expect( fail4.message.length > 0 ).toEqual( true );
    67 84   
    68  - const fail5 = CheckInput( 'INPUT', 'font1', ['color1'], 'bgcolor1', 'left', ['color1'], false, FONTFACES, COLORS, BGCOLORS, COLORS, ALIGNMENT );
     85 + const fail5 = CheckInput( 'INPUT', 'font1', ['color1'], 'bgcolor1', 'left', ['color1'], false, FONTFACES, COLORS, BGCOLORS, COLORS, GRADIENTS, ALIGNMENT );
    69 86   expect( fail5.pass ).toEqual( false );
    70 87   expect( fail5.message.length > 0 ).toEqual( true );
    71 88   
    72  - const fail6 = CheckInput( 'INPUT', 'font1', ['color1'], 'bgcolor1', 'left', ['notfound','color1'], false, FONTFACES, COLORS, BGCOLORS, COLORS, ALIGNMENT );
     89 + const fail6 = CheckInput( 'INPUT', 'font1', ['color1'], 'bgcolor1', 'left', ['notfound','color1'], false, FONTFACES, COLORS, BGCOLORS, COLORS, GRADIENTS, ALIGNMENT );
    73 90   expect( fail6.pass ).toEqual( false );
    74 91   expect( fail6.message.length > 0 ).toEqual( true );
    75 92   
    76  - const fail7 = CheckInput( 'INPUT', 'font1', ['color1'], 'bgcolor1', 'left', ['color2','#egz'], false, FONTFACES, COLORS, BGCOLORS, COLORS, ALIGNMENT );
     93 + const fail7 = CheckInput( 'INPUT', 'font1', ['color1'], 'bgcolor1', 'left', ['color2','#egz'], false, FONTFACES, COLORS, BGCOLORS, COLORS, GRADIENTS, ALIGNMENT );
    77 94   expect( fail7.pass ).toEqual( false );
    78 95   expect( fail7.message.length > 0 ).toEqual( true );
    79 96   
    80  - const fail8 = CheckInput( 'INPUT', 'font1', ['color1'], 'bgcolor1', 'left', ['color1','color2','color3'], false, FONTFACES, COLORS, BGCOLORS, COLORS, ALIGNMENT );
     97 + const fail8 = CheckInput( 'INPUT', 'font1', ['color1'], 'bgcolor1', 'left', ['color1','color2','color3'], false, FONTFACES, COLORS, BGCOLORS, COLORS, GRADIENTS, ALIGNMENT );
    81 98   expect( fail8.pass ).toEqual( false );
    82 99   expect( fail8.message.length > 0 ).toEqual( true );
    83 100   
    84  - const fail9 = CheckInput( 'INPUT', 'font1', ['color1'], 'bgcolor1', 'left', ['color1'], true, FONTFACES, COLORS, BGCOLORS, COLORS, ALIGNMENT );
     101 + const fail9 = CheckInput( 'INPUT', 'font1', ['color1'], 'bgcolor1', 'left', ['color1'], true, FONTFACES, COLORS, BGCOLORS, COLORS, GRADIENTS, ALIGNMENT );
    85 102   expect( fail9.pass ).toEqual( false );
    86 103   expect( fail9.message.length > 0 ).toEqual( true );
     104 + 
     105 + const fail10 = CheckInput( 'INPUT', 'font1', ['color1'], 'bgcolor1', 'left', ['set2'], false, FONTFACES, COLORS, BGCOLORS, COLORS, GRADIENTS, ALIGNMENT );
     106 + expect( fail10.pass ).toEqual( false );
     107 + expect( fail10.message.length > 0 ).toEqual( true );
    87 108  });
    88 109   
  • ■ ■ ■ ■ ■ ■
    test/unit/Gradient.spec.js
    skipped 262 lines
    263 263   expect( Transition( ['#ff0000', '#00ff00', '#0000ff'], 2 ) ).toEqual( [ '#ff0000', '#0000ff' ] );
    264 264   expect( Transition( ['#ff0000', '#00ff00', '#0000ff'], 3 ) ).toEqual( [ '#ff0000', '#00ff00', '#0000ff' ] );
    265 265   expect( Transition( ['#ff0000', '#00ff00', '#0000ff'], 4 ) ).toEqual( [ '#ff0000', '#00ff00', '#007f7f', '#0000ff' ] );
    266  - expect( Transition( ['#ff0000', '#00ff00', '#0000ff'], 10 ) ).toEqual( [
     266 + expect( Transition( ['#ff0000', '#00ff00', '#0000ff'], 10 ) ).toEqual([
    267 267   '#ff0000',
    268 268   '#bf3f00',
    269 269   '#7f7f00',
    skipped 4 lines
    274 274   '#006699',
    275 275   '#0033cc',
    276 276   '#0000ff',
    277  - ] );
     277 + ]);
     278 + 
     279 + expect( Transition( ['set2'], 2, { set2: [ '#ff0000', '#0000ff' ] } ) ).toEqual( [ '#ff0000', '#0000ff' ] );
     280 + expect( Transition( ['set2'], 4, { set2: [ '#ff0000', '#0000ff' ] } ) ).toEqual( [ '#ff0000', '#aa0055', '#5500aa', '#0000ff' ] );
    278 281  });
    279 282   
    280 283  test(`Gradient - PaintGradient - Should paint multi-line output`, () => {
    skipped 49 lines
    330 333   ]);
    331 334  });
    332 335   
     336 +test(`Gradient - PaintGradient - Should paint multi-line output for transitions`, () => {
     337 + const output1 = PaintGradient({
     338 + output: ['x','xxx','xxx','x'],
     339 + gradient: ['red','blue'],
     340 + lines: 4,
     341 + lineHeight: 0,
     342 + fontLines: 1,
     343 + independentGradient: false,
     344 + transitionGradient: true,
     345 + });
     346 + 
     347 + expect( output1 ).toEqual([
     348 + '\u001b[38;2;255;0;0mx\u001b[39m',
     349 + '\u001b[38;2;255;0;0mx\u001b[39m\u001b[38;2;127;0;127mx\u001b[39m\u001b[38;2;0;0;255mx\u001b[39m',
     350 + '\u001b[38;2;255;0;0mx\u001b[39m\u001b[38;2;127;0;127mx\u001b[39m\u001b[38;2;0;0;255mx\u001b[39m',
     351 + '\u001b[38;2;255;0;0mx\u001b[39m',
     352 + ]);
     353 + 
     354 + const output2 = PaintGradient({
     355 + output: [' x','xxxxxxxx','xxx','x'],
     356 + gradient: ['pride'],
     357 + lines: 4,
     358 + lineHeight: 0,
     359 + fontLines: 1,
     360 + independentGradient: false,
     361 + transitionGradient: true,
     362 + });
     363 + 
     364 + expect( output2 ).toEqual([
     365 + '\u001b[38;2;117;7;135m \u001b[39m\u001b[38;2;0;77;255mx\u001b[39m',
     366 + '\u001b[38;2;117;7;135mx\u001b[39m\u001b[38;2;0;77;255mx\u001b[39m\u001b[38;2;0;128;38mx\u001b[39m\u001b[38;2;255;237;0mx\u001b[39m\u001b[38;2;255;188;0mx\u001b[39m\u001b[38;2;255;140;0mx\u001b[39m\u001b[38;2;241;71;1mx\u001b[39m\u001b[38;2;228;3;3mx\u001b[39m',
     367 + '\u001b[38;2;117;7;135mx\u001b[39m\u001b[38;2;0;77;255mx\u001b[39m\u001b[38;2;0;128;38mx\u001b[39m',
     368 + '\u001b[38;2;117;7;135mx\u001b[39m',
     369 + ]);
     370 +});
     371 + 
  • ■ ■ ■ ■ ■ ■
    test/unit/constants.spec.js
    skipped 9 lines
    10 10   COLORS,
    11 11   BGCOLORS,
    12 12   GRADIENTCOLORS,
     13 + GRADIENTS,
    13 14   ALIGNMENT,
    14 15   FONTFACES,
    15 16   CLIOPTIONS,
    skipped 18 lines
    34 35   
    35 36  test(`GRADIENTCOLORS - Should have n number of colors defined`, () => {
    36 37   expect( Object.keys( GRADIENTCOLORS ).length > 0 ).toEqual( true );
     38 +});
     39 + 
     40 + 
     41 +test(`GRADIENTS - Should have n number of colors defined`, () => {
     42 + expect( Object.keys( GRADIENTS ).length > 0 ).toEqual( true );
    37 43  });
    38 44   
    39 45   
    skipped 26 lines
Please wait...
Page is in error, reload to recover