Skip to article

transform

transform() maps an input range to numbers, colours, or complex strings.

transform can map an input value from one range of values to another.

const numberToColor = transform(
  [0, 100], // Input
  ["#000", "#fff"] // Output
)

numberToColor(50) // rgba(128, 128, 128, 1)

Usage

Import transform from Motion.

import { transform } from "motion"

A transformation function can be created by passing two ranges, an input range and an output range:

const transformer = transform([0, 100], [0, 360])