Function

@ux, @uy

The pointer position over the doodle, in pixels from its top-left corner, updated as the pointer moves.

Syntax

  • @ux, @ux(<operation>, ...)
  • @uy, @uy(<operation>, ...)

The values are unitless numbers in CSS variables, so multiply by 1px to get a length, or divide by @uw and @uh for a 0–1 ratio. They start at 0 until the pointer first moves over the element. Inside $() the math around them is written out as CSS math, so $(@ux - @uy)deg is an angle that follows the pointer.

Examples

Move the pointer over the doodles:

@grid: 1 / 60vmin;
@size: 20%;
@place: @ux(*1px) @uy(*1px);
border-radius: 50%;
background: #000;

Or, with a little math, to color a gradient:

@grid: 1 / 60vmin;
background: conic-gradient(
  from $(@ux - @uy)deg,
  hsl($(@ux * 2)deg, 85%, 55%),
  hsl($(120 + @uy * 2)deg, 85%, 65%),
  hsl($(240 + @ux + @uy)deg, 85%, 45%),
  hsl($(@ux * 2)deg, 85%, 55%)
);

See also