Pixel UI/Physics & time/Liquid

Liquid

Your section half full of pixel water, and the things in it float.

<piix-liquid>DOM + canvas

Make a splash.

Floats

Rides the waves.

Still clickable
Water
Level
Pixel

A tank of water drawn in pixels across your section, at the level you choose. Anything whose bottom sits below the waterline rises and floats on the surface: it rides up and down on the wave beneath it, tilts with the slope, and pushes waves back as it bobs. Move the pointer through the water and it ripples; click and it splashes, throwing droplets that fall back in; scroll fast and the whole tank sloshes. Everything stays real: links and buttons work, even half under water.

Installation

<!-- once, anywhere on the page: every component -->
<script src="https://cdn.jsdelivr.net/npm/piixpal@0.6/piixpal.min.js"></script>

Usage

<piix-liquid level=".45" style="height:420px;padding:28px 32px;box-sizing:border-box">
  <h2 class="ex-h2">Make a splash.</h2>
  <div style="display:flex;gap:16px;align-items:flex-end;margin-top:150px">
    <piix-glow-card style="width:200px"><h3>Floats</h3><p>Rides the waves.</p></piix-glow-card>
    <piix-button tone="coral">Still clickable</piix-button>
  </div>
</piix-liquid>

Examples

A lava lake

Same physics, different palette. calm sets how long the waves last.

Don't touch the floor

Raft

Splash from code

splash(x, strength) drops something in, x in px from the left.

Drop a rock

API reference

AttributeWhat it doesDefault
levelhow full, from 0 (empty) to 1 (brim).55
palettelagoon ocean slime lava inklagoon
pixelsize of one pixel of water, in px3
calmhow fast waves die down, 0 (they last) to 1 (at once).3
soundmake sounds even without <piix-chiptune>; off keeps it silent–
data-anchoredon an element inside: it stays where it is, even under water–
data-floaton a box inside: it floats as one piece instead of each thing in it floating alone–

Events

EventWhen
splasha click or splash() drops something in: detail.x

Methods

MethodWhat it does
splash(x, strength)drop something in at x (px from the left); strength around 1

Accessibility