:rainbow: 终端输出中的漂亮色彩渐变
[![构建状态][build-src]][build-href] [![版本][version-src]][version-href] [![Codecov][codecov-src]][codecov-href] [![下载][downloads-src]][downloads-href] [![代码风格: prettier][code-style-src]][code-style-href] [![在 Awesome Node.js 中提及][awesome-src]][awesome-href]
终端输出中的美观色彩渐变
$ npm i gradient-stringimport gradient from 'gradient-string';
console.log(gradient(['cyan', 'pink'])('Hello world!'));// Provide an array of colors
const coolGradient = gradient(['#FF0000', '#00FF00', '#0000FF']);颜色使用 TinyColor 解析, 支持多种格式。
const coolGradient = gradient([
tinycolor('#FFBB65'), // tinycolor object
{ r: 0, g: 255, b: 0 }, // RGB object
{ h: 240, s: 1, v: 1, a: 1 }, // HSVa object
'rgb(120, 120, 0)', // RGB CSS string
'gold', // named color
]);const coolString = coolGradient('This is a fancy string!');
console.log(coolString);import { rainbow, pastel } from 'gradient-string';
// Use the pastel built-in gradient
console.log(pastel('I love gradient-string!'));
// Use the rainbow built-in gradient
console.log(rainbow('It is so pretty! '));在某些情况下,您可能希望在长文本的每一行(或 ASCII 图形)上应用相同的水平渐变。您可以使用渐变的 multiline() 方法来确保颜色垂直对齐。
暂无开放 Issues,或尚未同步最近议题。