Package me.hackware.api.gui
Class Ripple
java.lang.Object
me.hackware.api.gui.Ripple
Port of nextui's
Ripple.tsx (JoshMerlino/nextui, new-components): on
press, a circle of the element's text colour (bg-current at the
container's opacity-20) emits from the click point and grows to
(max(w,h) + distFromCenter * 1.875) * 1.1 over 500ms along
cubic-bezier(0, .5, 0, .75); it holds while pressed and fades out over
2 × duration on release. Clipped to the pressed element's rounded
surface.
Multiple ripples can be live at once — rapid presses each spawn their own instance, and earlier ones keep growing/fading independently.
The bezier's x control points are both 0, so x(t) = t³ — progress
inverts exactly via t = ∛x, no iterative solve needed.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intZ-layers a ripple can belong to.static final intstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidrelease()Begins the fade-out (mouseup) for every held ripple; growth keeps animating.voidRenders every live ripple regardless of layer — the single-pass default.voidRenders the ripples on z-layer(or all layers whenlayer < 0).voidrender(UiContext, int)with every ripple on this layer scaled byalphaScale— so ripples on a surface that is itself fading (a closing confirm dialog) go with it instead of hanging at full strength over it.voidtrigger(int x, int y, int w, int h, double clickX, double clickY, int color, int surfaceRadiusPx) Starts a ripple on press.voidtrigger(int x, int y, int w, int h, double clickX, double clickY, int color, int layer, int surfaceRadiusPx) Single-radius variant on an explicit z-layer(LAYER_CONTENTetc).voidtrigger(int x, int y, int w, int h, double clickX, double clickY, int color, int tlPx, int trPx, int blPx, int brPx) Per-corner radii (tl, tr, bl, br) for the clip surface, onLAYER_CONTENT.voidtrigger(int x, int y, int w, int h, double clickX, double clickY, int color, int layer, int tlPx, int trPx, int blPx, int brPx) Canonical trigger: per-corner clip radii on an explicit z-layer.
-
Field Details
-
LAYER_CONTENT
public static final int LAYER_CONTENTZ-layers a ripple can belong to. A ripple renders in the pass for the surface it was pressed on, so its clicked control keeps a Material ripple even when a higher layer (a popover it opens, a modal it lives in) draws over that control: the popover covers aLAYER_CONTENTripple, while aLAYER_MODALbutton's ripple still lands over the modal. Values are pass identifiers only, not a magnitude — screens choose when each runs.- See Also:
-
LAYER_OVERLAY
public static final int LAYER_OVERLAY- See Also:
-
LAYER_MODAL
public static final int LAYER_MODAL- See Also:
-
-
Constructor Details
-
Ripple
public Ripple()
-
-
Method Details
-
trigger
public void trigger(int x, int y, int w, int h, double clickX, double clickY, int color, int surfaceRadiusPx) Starts a ripple on press.coloris the element's text colour (bg-current);surfaceRadiusPxis the pressed surface's corner radius so the ripple clips to its rounded shape (overflow-hidden). -
trigger
public void trigger(int x, int y, int w, int h, double clickX, double clickY, int color, int layer, int surfaceRadiusPx) Single-radius variant on an explicit z-layer(LAYER_CONTENTetc). -
trigger
public void trigger(int x, int y, int w, int h, double clickX, double clickY, int color, int tlPx, int trPx, int blPx, int brPx) Per-corner radii (tl, tr, bl, br) for the clip surface, onLAYER_CONTENT. -
trigger
public void trigger(int x, int y, int w, int h, double clickX, double clickY, int color, int layer, int tlPx, int trPx, int blPx, int brPx) Canonical trigger: per-corner clip radii on an explicit z-layer. -
release
public void release()Begins the fade-out (mouseup) for every held ripple; growth keeps animating. -
render
Renders every live ripple regardless of layer — the single-pass default. -
render
Renders the ripples on z-layer(or all layers whenlayer < 0). Split a screen's singlerender(ui)into one call per layer, each at that layer's depth in the frame, and a control's ripple stays with its surface. A pass whose layer has no live ripples draws nothing.Fade-out and expiry are layer-independent: every pass prunes fully-faded instances across all layers, so a released ripple whose layer stopped rendering (its popover closed) can't linger — provided some pass runs each frame, which the always-present content pass guarantees.
-
render
render(UiContext, int)with every ripple on this layer scaled byalphaScale— so ripples on a surface that is itself fading (a closing confirm dialog) go with it instead of hanging at full strength over it. Draw this pass inside that surface's transform and the ripples scale with it too.
-