Skip to main content

Overview

The rgbDefaults object defines the default configuration for gradient text generation. It contains all settings for colors, formatting, output formats, and gradient behavior.

rgbDefaults

Default configuration object for gradient generation.
const rgbDefaults: {
  version: number;
  colors: Array<{ hex: string; pos: number }>;
  shadowcolors: null | Array<{ hex: string; pos: number }>;
  colorlength: number;
  text: string;
  format: format;
  prefixsuffix: string;
  customFormat: boolean;
  trimspaces: boolean;
  disperse: boolean;
  lowercase: boolean;
  bold: boolean;
  italic: boolean;
  underline: boolean;
  strikethrough: boolean;
  obfuscate: boolean;
  gradientType: GradientType;
}

Properties

version
number
default:"4"
Configuration version number
colors
Array<{ hex: string; pos: number }>
Array of color stops defining the gradient.
  • hex: Hex color string (e.g., ‘#FF5733’)
  • pos: Position in gradient (0-100)
shadowcolors
null | Array<{ hex: string; pos: number }>
default:"null"
Optional shadow color stops for MiniMessage format. If null, auto-generates shadows at 25% brightness of main colors.
colorlength
number
default:"1"
Number of characters per color segment. Higher values = fewer color changes.
text
string
default:"'Birdflop'"
The text to apply the gradient to
format
format
default:"formats[1]"
Output format template. See Format Templates below.
prefixsuffix
string
default:"''"
Wrapper template with $t placeholder for the full output. Applied after all other formatting.
customFormat
boolean
default:"false"
Whether using a custom format template
trimspaces
boolean
default:"true"
Skip gradient for whitespace-only segments (preserves spacing)
disperse
boolean
default:"false"
Auto-distribute colors evenly (overrides pos values)
lowercase
boolean
default:"false"
Convert output to lowercase
bold
boolean
default:"false"
Apply bold formatting
italic
boolean
default:"false"
Apply italic formatting
underline
boolean
default:"false"
Apply underline formatting
strikethrough
boolean
default:"false"
Apply strikethrough formatting
obfuscate
boolean
default:"false"
Apply obfuscated/magic text formatting (Minecraft)
gradientType
GradientType
default:"'rgb'"
Gradient interpolation type: ‘rgb’, ‘hsl’, ‘oklab’, ‘oklch’, ‘cielab’, or ‘luvLch’. See Gradient Types.

format Interface

Defines the output format template structure.
interface format {
  color: string;
  char?: string;
  class?: string;
  bold?: string;
  italic?: string;
  underline?: string;
  strikethrough?: string;
  obfuscate?: string;
}
color
string
required
Color format template using placeholders:
  • $1 through $6: Individual hex digits
  • $f: Format codes (bold, italic, etc.)
  • $c: The character/text segment
  • Special values: ‘MiniMessage’, ‘JSON’
char
string
Format character for Minecraft-style codes (e.g., ’&’ or ’§’)
class
string
CSS class for web output (future use)
bold
string
Bold wrapper template with $t placeholder
italic
string
Italic wrapper template with $t placeholder
underline
string
Underline wrapper template with $t placeholder
strikethrough
string
Strikethrough wrapper template with $t placeholder
obfuscate
string
Obfuscate wrapper template with $t placeholder

Format Templates

Pre-defined format templates in the formats array:

MiniMessage (index 0)

{
  color: 'MiniMessage',
  bold: '<b>$t</b>',
  italic: '<i>$t</i>',
  underline: '<u>$t</u>',
  strikethrough: '<st>$t</st>',
  obfuscate: '<obf>$t</obf>'
}
Generates MiniMessage format: <gradient:#color1:#color2>text</gradient>

Bukkit/Spigot Ampersand (index 1, default)

{
  color: '&#$1$2$3$4$5$6$f$c',
  char: '&'
}
Generates: &#F&#F&#5&#7&#3&#3&ltext (if bold)

JSON (index 2)

{
  color: 'JSON'
}
Generates JSON tellraw format:
{
  "text": "",
  "extra": [
    {"text": "T", "color": "#FF0000", "bold": true},
    {"text": "e", "color": "#FF3300"},
    ...
  ]
}

Section Sign (index 3)

{
  color: '§x§$1§$2§$3§$4§$5§$6$f$c',
  char: '§'
}

CMI/Essentials Ampersand (index 4)

{
  color: '&x&$1&$2&$3&$4&$5&$6$f$c',
  char: '&'
}

DeluxeMenus/AdvancedBan (index 5)

{
  color: '<#$1$2$3$4$5$6>$f$c',
  char: '&'
}

BBCode (index 6)

{
  color: '[COLOR=#$1$2$3$4$5$6]$c[/COLOR]',
  bold: '[BOLD]$t[/BOLD]',
  italic: '[ITALIC]$t[/ITALIC]',
  underline: '[UNDERLINE]$t[/UNDERLINE]',
  strikethrough: '[STRIKETHROUGH]$t[/STRIKETHROUGH]'
}

Usage Examples

Basic Configuration

import { generateOutput, rgbDefaults } from '@birdflop/rgbirdflop';

const config = {
  ...rgbDefaults,
  text: 'Hello World',
  colors: [
    { hex: '#FF0000', pos: 0 },
    { hex: '#0000FF', pos: 100 }
  ]
};

const output = generateOutput(config);

MiniMessage Format

const config = {
  ...rgbDefaults,
  text: 'Gradient Text',
  colors: [
    { hex: '#54daf4', pos: 0 },
    { hex: '#545eb6', pos: 100 }
  ],
  format: { color: 'MiniMessage' },
  bold: true
};

const output = generateOutput(config);
// Output: <b><gradient:#54daf4:#545eb6>Gradient Text</gradient></b>

Custom Format

const config = {
  ...rgbDefaults,
  text: 'Custom',
  colors: [{ hex: '#FF5733', pos: 0 }],
  format: {
    color: '<span style="color: #$1$2$3$4$5$6">$c</span>',
  },
  customFormat: true
};

const output = generateOutput(config);
// Output: <span style="color: #FF5733">Custom</span>

With Prefix/Suffix

const config = {
  ...rgbDefaults,
  text: 'Server',
  colors: [
    { hex: '#FFD700', pos: 0 },
    { hex: '#FFA500', pos: 100 }
  ],
  format: { color: 'MiniMessage' },
  prefixsuffix: '[Premium] $t [VIP]'
};

const output = generateOutput(config);
// Output: [Premium] <gradient:#FFD700:#FFA500>Server</gradient> [VIP]

Multi-Color with Custom Positions

const config = {
  ...rgbDefaults,
  text: 'Rainbow',
  colors: [
    { hex: '#FF0000', pos: 0 },
    { hex: '#FFFF00', pos: 33 },
    { hex: '#00FF00', pos: 66 },
    { hex: '#0000FF', pos: 100 }
  ],
  format: { color: 'MiniMessage' },
  gradientType: 'hsl' as const
};

const output = generateOutput(config);

Longer Color Segments

const config = {
  ...rgbDefaults,
  text: 'Longer Segments',
  colors: [
    { hex: '#FF0000', pos: 0 },
    { hex: '#0000FF', pos: 100 }
  ],
  colorlength: 3, // 3 characters per color
  format: { color: 'MiniMessage' }
};

// Each color applies to 3 characters instead of 1

Utility Functions

disperseColors

Auto-distributes colors evenly across the gradient.
function disperseColors(
  colors: typeof rgbDefaults.colors
): Array<{ hex: string; pos: number }>
colors
Array<{ hex: string; pos: number }>
required
Input color array (pos values are ignored)
distributedColors
Array<{ hex: string; pos: number }>
Colors with evenly distributed positions

Example

import { disperseColors } from '@birdflop/rgbirdflop';

const colors = [
  { hex: '#FF0000', pos: 0 },
  { hex: '#00FF00', pos: 0 },
  { hex: '#0000FF', pos: 0 }
];

const dispersed = disperseColors(colors);
// Returns: [
//   { hex: '#FF0000', pos: 0 },
//   { hex: '#00FF00', pos: 50 },
//   { hex: '#0000FF', pos: 100 }
// ]

sortColors

Sorts colors by position.
function sortColors(
  colors: Array<{ hex: string; pos: number }>
): Array<{ hex: string; pos: number }>

swapItems

Swaps two items in an array, maintaining pos values if present.
function swapItems(array: any[], indexA: number, indexB: number): any[]
array
any[]
required
Array to swap items in
indexA
number
required
First index (supports negative wrapping)
indexB
number
required
Second index (supports negative wrapping)
swappedArray
any[]
New array with swapped items

getShadowColors

Generates shadow colors for the gradient (auto-darkens or uses custom).
function getShadowColors(
  rgbStore: typeof rgbDefaults
): Array<{ hex: string; pos: number }>

Implementation

Source: packages/rgbirdflop/src/util/Defaults.ts:58

Build docs developers (and LLMs) love