Skip to content
pixi-silk
GitHub repository
Entry point

pixi-silk/ui/arc

Angle maths for ring widgets: angleDelta, wrapAngle, snapTo, rubberBand.

import { AngleAccumulator, TAU, angleDelta, clamp } from 'pixi-silk/ui/arc';

Classes#

ClassDescription
AngleAccumulatorFollows a pointer around a centre and counts full turns, so dragging past the seam keeps adding up instead of jumping back by a turn. total is the angle travelled since reset.

Variables#

VariableDescription
TAUA full turn in radians, 2 * Math.PI.

Functions#

FunctionDescription
angleDeltaSigned shortest turn from b to a, in -PI..PI radians. Inputs can be any size.
clampClamps v to min..max. Expects min <= max.
rubberBandSoft limit: inside min..max the value passes through, past a limit it keeps moving but slows down and never goes further than limit beyond it (the rubber band of scroll views). A limit of 0 or less is a hard clamp.
snapToRounds value to the nearest origin + k * step. A step of 0 or less returns value unchanged.
wrapAngleWraps an angle of any size into 0..TAU radians.