Skip to content
colors

adjustHue

The `adjustHue` function rotates the hue of a HEX color by a specified number of degrees. It preserves saturation and lightness while shifting the color’s position on the color wheel.

1 min read154 words

Function Signature

js

adjustHue(hex: string, degrees: number): string

Parameters

  • hex (string): A HEX color string (e.g., #ff6600).
  • degrees (number): The number of degrees to rotate the hue. Can be positive or negative.

Return Value

Returns a HEX color string with the hue rotated by the specified degree value, always in the format #rrggbb.

js

adjustHue("#ff6600", 180);
// "#0099ff"

adjustHue("#00aaff", -90);
// "#aaff00"

Examples

js

// Rotate hue by +120° (orange → green)
console.log(adjustHue("#ff6600", 120));
// "#66ff00"

// Rotate hue by -120° (orange → magenta)
console.log(adjustHue("#ff6600", -120));
// "#cc00ff"

Implementation Details

  • Converts the HEX input to RGB values using hexToRgb.
  • Transforms RGB into HSL using rgbToHsl.
  • Adjusts the hue by the given degree value and normalizes it with mod360.
  • Converts back to RGB via hslToRgb, then returns HEX with rgbToHex.

Usage Notes

  • Hue rotation wraps around the color wheel, ensuring values remain within 0–360 degrees.
  • Negative values rotate the hue counter-clockwise, positive values clockwise.
  • Often used in generating complementary, triadic, or analogous color schemes.

Previous

desaturate

Next

invert


Top tools

WorkspaceLinksySEO AnalyzerChromoQR Code Generator

ReadyTools

CareersContactTools
Pricing7 days free
SupportSecurityGuidesDocsBlogUpdatesLaraVault

Select Language

Set theme

ReadyTools

© 2026 ReadyTools. All rights reserved.