ElectronCSS / CubicGradient.js

Cubic
Gradient

Power-curve eased CSS gradients with automatic stop optimization. Generates minimal linear-gradient() strings with intelligently pruned color stops — no redundancy, no bloat.

Designer Presets QUICK LOAD
Gradient Customizer
32
3
HUD
Steps Evaluated
Optimized Stops
Compression Savings
CSS Output
background: ;
Committed Stops
Website Integration Guide
Guide Importing & Using CubicGradient.js

		
Technical Deep Dive
01 / Mathematics
Power Curve Plotting
Each color stop's position is mapped through a power function rather than simple linear interpolation. For a normalized parameter t ∈ [0,1], the eased value is: eased = t ^ power This concentrates visual change near the gradient's start when power > 1, producing the characteristic "snap" of cubic and quadratic curves. A power of 1 gives a flat linear transition; higher powers create increasingly sharp leading edges followed by a smooth tail.
02 / Algorithm
Precision Checking
Before committing each candidate stop, the optimizer verifies whether it lies within 0.5 channel units of a straight line connecting the previous committed stop and the next candidate. For each RGBA channel: |curr[ch] − lerp(prev, next, t)| < 0.5 If all four channels pass this threshold the point is considered collinear and silently discarded — only stops where the curve genuinely deviates from linearity earn a place in the output.
03 / Optimization
Linearity Reduction
The single-pass generator evaluates all candidate T-values derived from per-channel color step counts and commits only deviating stops. The result is a minimal CSS payload: a high-power easing curve faithfully represented with the fewest possible color stops. This simultaneously reduces browser paint complexity, CSS payload byte count, and GPU interpolation workload — without any perceptible loss in gradient fidelity.