Skip to main content
Glama

generate_color_variations

Generate tints, shades, and tones from a base color using mathematical precision for design consistency and palette expansion.

Instructions

Generate tints, shades, and tones of a base color with mathematical precision. Tints add white, shades add black, and tones add gray.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
base_colorYesBase color for generating variations
variation_typeYesType of variations to generate
stepsNoNumber of variation steps (3-20)
intensityNoVariation intensity percentage (0-100)

Implementation Reference

  • The ToolHandler implementation for 'generate_color_variations' tool, defining name, description, input schema, and the handler function.
    export const generateColorVariationsTool: ToolHandler = { name: 'generate_color_variations', description: 'Generate tints, shades, and tones of a base color with mathematical precision. Tints add white, shades add black, and tones add gray.', parameters: { type: 'object', properties: { base_color: { type: 'string', description: 'Base color for generating variations', }, variation_type: { type: 'string', enum: ['tints', 'shades', 'tones', 'all'], description: 'Type of variations to generate', }, steps: { type: 'number', minimum: 3, maximum: 20, default: 10, description: 'Number of variation steps (3-20)', }, intensity: { type: 'number', minimum: 0, maximum: 100, default: 50, description: 'Variation intensity percentage (0-100)', }, }, required: ['base_color', 'variation_type'], }, handler: generateVariationsHandler, };
  • Joi validation schema used internally for parameter validation in the handler.
    const generateVariationsSchema = Joi.object({ base_color: Joi.string().required().messages({ 'string.empty': 'Base color is required', }), variation_type: Joi.string() .valid('tints', 'shades', 'tones', 'all') .required() .messages({ 'any.only': 'Variation type must be one of: tints, shades, tones, all', }), steps: Joi.number().integer().min(3).max(20).default(10).messages({ 'number.min': 'Minimum 3 steps required', 'number.max': 'Maximum 20 steps allowed', }), intensity: Joi.number().min(0).max(100).default(50).messages({ 'number.min': 'Intensity must be between 0 and 100', 'number.max': 'Intensity must be between 0 and 100', }), });
  • Registration of the generate_color_variations tool into the central tool registry.
    toolRegistry.registerTool(generateColorVariationsTool);
  • Helper function that generates tint variations by progressively increasing lightness from the base color.
    function generateTints( baseColor: UnifiedColor, steps: number, intensity: number ): UnifiedColor[] { const tints: UnifiedColor[] = []; const hsl = baseColor.hsl; // Generate tints by increasing lightness towards white for (let i = 0; i < steps; i++) { const factor = (i / (steps - 1)) * (intensity / 100); const newLightness = hsl.l + (100 - hsl.l) * factor; try { const tint = UnifiedColor.fromHsl( hsl.h, hsl.s, Math.min(100, Math.max(0, newLightness)), hsl.a ); tints.push(tint); } catch { // Skip invalid colors continue; } } return tints; }
  • Helper function that generates shade variations by progressively decreasing lightness from the base color.
    function generateShades( baseColor: UnifiedColor, steps: number, intensity: number ): UnifiedColor[] { const shades: UnifiedColor[] = []; const hsl = baseColor.hsl; // Generate shades by decreasing lightness towards black for (let i = 0; i < steps; i++) { const factor = (i / (steps - 1)) * (intensity / 100); const newLightness = hsl.l * (1 - factor); try { const shade = UnifiedColor.fromHsl( hsl.h, hsl.s, Math.min(100, Math.max(0, newLightness)), hsl.a ); shades.push(shade); } catch { // Skip invalid colors continue; } } return shades; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/keyurgolani/ColorMcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server