typst/typst · error

this color space does not support hue rotation

Error message

this color space does not support hue rotation

What it means

Raised by Color::rotate when the color's current space has no hue channel (e.g. luma, oklab, rgb, cmyk). Hue rotation is only defined for hue-based spaces like oklch, hsl, and hsv; the guard rejects rotation in spaces where hue is not a component.

Source

Thrown at crates/typst-library/src/visualize/color.rs:1063

                Self::Process(ProcessColor::Oklch(rotated))
                    .to_space(&self.space())
                    .at(span)?
            }
            ProcessColorSpace::Hsl => {
                let hsl = self.to_hsl();
                let rotated = hsl.shift_hue(angle.to_deg() as f32);
                Self::Process(ProcessColor::Hsl(rotated))
                    .to_space(&self.space())
                    .at(span)?
            }
            ProcessColorSpace::Hsv => {
                let hsv = self.to_hsv();
                let rotated = hsv.shift_hue(angle.to_deg() as f32);
                Self::Process(ProcessColor::Hsv(rotated))
                    .to_space(&self.space())
                    .at(span)?
            }
            _ => bail!(span, "this color space does not support hue rotation"),
        })
    }

    /// Create a color by mixing two or more colors.
    ///
    /// In color spaces with a hue component (HSL, HSV, Oklch), only two colors
    /// can be mixed at once. Mixing more than two colors in such a space will
    /// result in an error!
    ///
    /// ```example
    /// #set block(height: 20pt, width: 100%)
    /// #block(fill: red.mix(blue))
    /// #block(fill: red.mix(blue, space: rgb))
    /// #block(fill: color.mix(red, blue, white))
    /// #block(fill: color.mix((red, 70%), (blue, 30%)))
    /// ```
    #[func(since = "0.7.0")]
    pub fn mix(

View on GitHub (pinned to 6a6f1a97a3)

Solutions

  1. Convert the color to oklch, hsl, or hsv before rotating the hue
  2. Use color.to-space(color.oklch) then rotate, then convert back if needed
  3. Pick a hue-based color space when hue manipulation is intended
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at crates/typst-library/src/visualize/color.rs:1054 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of typst/typst@6a6f1a97a3 (2026-08-17). Data as JSON: /api/errors/2550558d7176a0d3. Report an issue: GitHub.