Avenra
Liquid GlassAPI Reference
Liquid GlassAPI Reference

PROFILES

Built-in lens surface curvature functions.

PROFILES

An object containing built-in surface curvature profile functions used by compute1D to calculate refraction.

Members

KeyFormulaVisual Effect
convexSquircle(1-(1-x)^4)^(1/4)Default — smooth squircle-based convex lens
convexCirclesqrt(1-(1-x)^2)Traditional circular convex lens
concave1-sqrt(1-(1-x)^2)Inward-curving (concave) lens

Custom Profiles

Any function with the signature (x: number) => number can be used as a profile. The input x ranges from 0 (edge of the bezel) to 1 (inner edge of the bezel). The return value determines the virtual "height" or "depth" of the glass at that point.

// A simple linear ramp profile
const linearProfile = (x) => x;

createLiquidGlass('#my-el', {
  profile: linearProfile
});

On this page