### Local development commands Source: https://github.com/amarnath3003/quickliquid/blob/master/README.md Local development setup: install dependencies, type-check, build the library, and start the demo workspace. ```bash npm install npm run typecheck npm run build:lib npm run dev ``` -------------------------------- ### Install quick-liquid with npm Source: https://github.com/amarnath3003/quickliquid/blob/master/packages/quick-liquid/README.md Install the library via npm. Requires Node 18+ for local builds, and React 18+ only if using the React integration. No stylesheet import is required. ```bash npm install quick-liquid ``` -------------------------------- ### Material preset configuration example Source: https://github.com/amarnath3003/quickliquid/blob/master/packages/quick-liquid/README.md Example configuration object for a material preset. Start with a material and override only the knobs you need. This shows a 'regular' material with custom blur, refractionStrength, and tintOpacity. ```ts const config = { material: 'regular', blur: 18, refractionStrength: 20, tintOpacity: 0.08, }; ``` -------------------------------- ### Run dev server: npm run dev:landing Source: https://github.com/amarnath3003/quickliquid/blob/master/landingPage/README.md Starts the Vite dev server for the landing page from the repository root. The comment notes that it imports quick-liquid directly from src/. ```bash npm run dev:landing # vite dev server (imports quick-liquid straight from src/) ``` -------------------------------- ### Get performance metrics with getPerformanceMetrics() Source: https://github.com/amarnath3003/quickliquid/blob/master/packages/quick-liquid/README.md Retrieves live performance metrics from the LiquidGlassEngine instance. The returned object includes mapGenMs, mapPixelsComputed, avgFrameTime, mapEncodeMs, and displacementTaps; avgFrameTime is lighting callback CPU time, not FPS, and mapEncodeMs is asynchronous encoding latency. ```ts const metrics = glass.getPerformanceMetrics(); console.log(metrics.mapGenMs, metrics.mapPixelsComputed); ``` -------------------------------- ### Chromatic aberration scale formulas Source: https://github.com/amarnath3003/quickliquid/blob/master/packages/quick-liquid/PHYSICS.md Defines the per-channel scale factors for the displacement map to achieve chromatic aberration. The red channel uses a scale of S·(1 − 0.10·ca), green uses S, and blue uses S·(1 + 0.14·ca), where ca is the chromatic aberration strength. Blue bends more and gets a larger scale due to inward sampling. ```text S_R = S·(1 − 0.10·ca) S_G = S S_B = S·(1 + 0.14·ca) ``` -------------------------------- ### Build landing page: npm run build:landing Source: https://github.com/amarnath3003/quickliquid/blob/master/landingPage/README.md Builds the landing page: type-checks and emits static files to landingPage/dist. The output is fully static and can be deployed to any static host. ```bash npm run build:landing # type-checks then emits static files to landingPage/dist ``` -------------------------------- ### Import animation utilities from quick-liquid Source: https://github.com/amarnath3003/quickliquid/blob/master/packages/quick-liquid/README.md Imports the reusable animation primitives exported by `quick-liquid` alongside the glass engine. Use these utilities to build interactive liquid effects. ```ts import { LiquidButton, LiquidDrag, LiquidGesture, LiquidGroup, LiquidTabBar, Spring, } from 'quick-liquid'; ``` -------------------------------- ### Vanilla DOM usage: LiquidGlassEngine Source: https://github.com/amarnath3003/quickliquid/blob/master/packages/quick-liquid/README.md Use the LiquidGlassEngine class from 'quick-liquid' to apply liquid glass to an existing DOM element. Configure material, refractionStrength, dynamicLighting, and quality. Enable liquid press with scale and squish. ```ts import { LiquidGlassEngine } from 'quick-liquid'; const card = document.querySelector('[data-liquid-card]'); if (card) { const glass = new LiquidGlassEngine(card, { material: 'clear', refractionStrength: 28, dynamicLighting: true, quality: 'high', }); glass.enableLiquidPress({ scale: 0.94, squish: 0.025 }); } ``` -------------------------------- ### Create a LiquidTabBar with glass indicator Source: https://github.com/amarnath3003/quickliquid/blob/master/packages/quick-liquid/README.md Sets up a liquid tab bar with a glass indicator. Creates a `LiquidTabBar` with a 'snappy' spring, applies a clear glass material with `borderRadius: 999` to the indicator, and wires click events to select tabs. ```ts import { LiquidGlassEngine, LiquidTabBar } from 'quick-liquid'; const nav = document.querySelector('.tabs'); const tabs = [...document.querySelectorAll('.tab')]; if (nav && tabs.length) { const tabBar = new LiquidTabBar(nav, tabs, { spring: 'snappy' }); new LiquidGlassEngine(tabBar.getIndicator(), { material: 'clear', borderRadius: 999, }); tabs.forEach((tab, index) => { tab.addEventListener('click', () => tabBar.select(index)); }); } ``` -------------------------------- ### Update and clean up glass configuration with updateConfig, setConfig, destroy Source: https://github.com/amarnath3003/quickliquid/blob/master/packages/quick-liquid/README.md Shows how to update or replace the glass configuration at runtime. `updateConfig` merges explicit overrides, `setConfig` resets omitted values to defaults, and `destroy` releases resources when the view leaves. Pass `undefined` to remove an override. ```ts glass.updateConfig({ blur: 8 }); glass.updateConfig({ material: 'regular' }); // explicit blur remains 8 glass.updateConfig({ blur: undefined }); // returns to regular's blur glass.setConfig({ material: 'clear' }); // reset all overrides glass.destroy(); // release resources when the view leaves ``` -------------------------------- ### Create a LiquidButton with onTap handler Source: https://github.com/amarnath3003/quickliquid/blob/master/packages/quick-liquid/README.md Creates a liquid button from an existing element and registers a tap handler. The element is queried by the `.glass-button` selector; the handler logs 'Tapped' when tapped. ```ts import { LiquidButton } from 'quick-liquid'; const button = document.querySelector('.glass-button'); if (button) { new LiquidButton(button).onTap(() => { console.log('Tapped'); }); } ``` -------------------------------- ### React usage: LiquidGlass component Source: https://github.com/amarnath3003/quickliquid/blob/master/packages/quick-liquid/README.md Use the LiquidGlass component from 'quick-liquid/react' to wrap a button. Configure material, borderRadius, dynamicLighting, and chromaticAberration. Set liquidPress for press effects and animateIn for entrance animation. ```tsx import { LiquidGlass } from 'quick-liquid/react'; export function CommandButton() { return ( ); } ``` -------------------------------- ### v8 pad calculation formula Source: https://github.com/amarnath3003/quickliquid/blob/master/packages/quick-liquid/OPTIMIZATION.md Formula for the v8 padding, bucketed to specific values to keep blur sliders as attribute-only updates. ```text pad = ⌈2.5·blur⌉ + 2 (bucketed to {2, 8, 16, 24, 32, 40, 48, 64} so blur sliders stay attribute-only updates) ``` -------------------------------- ### 1-D reduction pipeline: SDF to LUT displacement Source: https://github.com/amarnath3003/quickliquid/blob/master/packages/quick-liquid/PHYSICS.md Shows the per-pixel pipeline for the 1-D reduction (LUT) approach. The SDF value d is converted to a normalized parameter s, which indexes a 512-entry lookup table to produce the displacement vector. This avoids per-pixel trigonometric and square-root operations beyond the SDF itself. ```text SDF(x,y) → d → s → lerp(LUT, s·512) → dx,dy = −m̂ · Δ̂(s) ``` -------------------------------- ### Dispersion channel expansions Source: https://github.com/amarnath3003/quickliquid/blob/master/packages/quick-liquid/OPTIMIZATION.md Shows the Taylor expansions for the three channel images around the green channel, used to derive the red channel extrapolation. ```text D(S_R) = D(S_G) + (S_R−S_G)·D′ + O(δ²) D(S_B) = D(S_G) + (S_B−S_G)·D′ + O(δ²) ``` -------------------------------- ### Rotation Transform for Light Disk Source: https://github.com/amarnath3003/quickliquid/blob/master/packages/quick-liquid/OPTIMIZATION.md JavaScript code to rotate the baked light disk using a compositor-only transform property, enabling efficient animation. ```javascript disk.style.transform = translate(-50%,-50%) rotate(θ_L) ``` -------------------------------- ### Filter graph with two displacement taps Source: https://github.com/amarnath3003/quickliquid/blob/master/packages/quick-liquid/OPTIMIZATION.md Shows the filter graph using only green and blue displacement taps, with red extrapolated via feComposite arithmetic, and final blending. ```text feImage → map dG = feDisplacementMap(SourceGraphic, map, S_G) ← dependent read dB = feDisplacementMap(SourceGraphic, map, S_B) ← dependent read T = feComposite(dG, dB, arithmetic, k2 = 1+λ, k3 = −λ) ← red extrapolation R = feColorMatrix(T, keep R) G = feColorMatrix(dG, keep G) B = feColorMatrix(dB, keep B) out = feBlend(screen, feBlend(screen, R, B), G) ← exact add: channels disjoint ``` -------------------------------- ### Map cell size per quality tier Source: https://github.com/amarnath3003/quickliquid/blob/master/packages/quick-liquid/OPTIMIZATION.md Selects the map cell size c per quality tier to bound map generation, PNG encode/decode, and GPU upload costs. The high tier uses a custom mapDensity override if needed. ```text high: c = min(1.5, B/10) (map pixels ÷ 2.25 for typical elements) medium: c = min(3, B/5) low: unchanged 128-px cap ``` -------------------------------- ### Merge elements into a LiquidGroup with drag updates Source: https://github.com/amarnath3003/quickliquid/blob/master/packages/quick-liquid/README.md Merges multiple elements into a liquid group. Configures `mergeDistance` and `blendRadius`, adds each `.dock-item` to the group, and updates positions on drag via `LiquidGesture`. ```ts import { LiquidGroup, LiquidGesture } from 'quick-liquid'; const container = document.querySelector('.dock'); const items = document.querySelectorAll('.dock-item'); if (container) { const group = new LiquidGroup(container, { mergeDistance: 60, blendRadius: 28, }); items.forEach((item) => { group.add(item); new LiquidGesture(item).onDrag(() => group.updatePositions()); }); } ``` -------------------------------- ### Intensity Profile Formula Source: https://github.com/amarnath3003/quickliquid/blob/master/packages/quick-liquid/OPTIMIZATION.md Mathematical formula for the rim/sheen intensity profile as a function of angle, showing the conic model with base, peak, and dark terms. ```text I(θ; θ_L) = base + peak·|cos(θ − θ_L)|^p − dark·sin²(θ − θ_L) ``` -------------------------------- ### Red channel extrapolation formula Source: https://github.com/amarnath3003/quickliquid/blob/master/packages/quick-liquid/OPTIMIZATION.md Gives the extrapolation formula for the red channel as a weighted combination of green and blue channels, with the lambda value. ```text D(S_R) ≈ (1+λ)·D(S_G) − λ·D(S_B) , λ = 0.10/0.14 = 5/7 ≈ 0.7143 ``` -------------------------------- ### Minimal-loss 8-bit encoding: map normalization and filter scale Source: https://github.com/amarnath3003/quickliquid/blob/master/packages/quick-liquid/PHYSICS.md Defines the minimal-loss 8-bit encoding for the displacement map. The map values are normalized to the full 0–255 range, and the filter scale is set to twice the maximum displacement M. This minimizes the quantization step in offset space, which is independent of the map's value range. ```text map values = Δ/Δmax ∈ [−1, 1] → full 0…255 range filter scale S = 2·M (M = refractionStrength px) ⇒ quantization step = 2M/255 ≈ M/127 (e.g. 0.17 px at M = 22) ``` -------------------------------- ### Error bound formula Source: https://github.com/amarnath3003/quickliquid/blob/master/packages/quick-liquid/OPTIMIZATION.md Provides the second-order error bound for the extrapolation, showing it is proportional to the second derivative and the displacement differences. ```text E = ½·D″·(S_R−S_G)(S_R−S_B) + O(δ³) ⇒ |E| ≤ ½·(0.10·ca·S)·(0.24·ca·S)·|D″| ``` -------------------------------- ### CA gate formulas and v8 gate rule Source: https://github.com/amarnath3003/quickliquid/blob/master/packages/quick-liquid/OPTIMIZATION.md Formulas for the chromatic aberration (CA) gate: per-channel sampling scales, the fringe as a directional-derivative signal, the effect of the frost blur, the surviving fringe amplitude, the 14% masked detection threshold, and the v8 gate rule. The gate builds the CA filter branch only when 0.24·ca·refractionStrength ≥ 0.35·blur. ```text S_R = S·(1 − 0.10·ca) S_G = S S_B = S·(1 + 0.14·ca) ``` ```text I_B − I_R ≈ split(x) · ∂I/∂m̂ , split(x) = (S_B − S_R)·Δ̂(x) = 0.24·ca·S·Δ̂(x) ``` ```text G_σ ∗ (split · ∂I/∂m̂) = split · ∂(G_σ ∗ I)/∂m̂ ``` ```text A_fringe = split_max / (σ·√2π) (fraction of full scale) ``` ```text CA invisible ⇔ A_fringe < 0.14 ⇔ split_max < 0.14·√2π·σ ≈ 0.35·σ ``` ```text 0.24 · ca · refractionStrength ≥ 0.35 · blur ``` -------------------------------- ### Missing Gaussian mass formula Source: https://github.com/amarnath3003/quickliquid/blob/master/packages/quick-liquid/OPTIMIZATION.md Formula for the missing Gaussian mass at a visible edge pixel at distance p from the border, used to determine the required padding. ```text missing(p) = ½·erfc( p / (σ√2) ) ``` -------------------------------- ### Rim error approximation formula Source: https://github.com/amarnath3003/quickliquid/blob/master/packages/quick-liquid/OPTIMIZATION.md Formula for the worst-case error at the first sample ring when reconstructing the displacement map with bilinear interpolation. Use to estimate the maximum rim error for a given cell size c and blur radius B. ```text E_rim ≈ S·√(2c/B)/4 ``` -------------------------------- ### Refraction sub-threshold gate condition Source: https://github.com/amarnath3003/quickliquid/blob/master/packages/quick-liquid/OPTIMIZATION.md Condition for dropping the entire SVG filter and reverting to the native blur+saturate fast path. The geometric shift of blurred content is detectable down to roughly 0.12σ, so v8 drops the filter when S is below the larger of 1.5 px and 0.12·blur. Defaults never trigger this; tiny-strength configs do. ```text S < max(1.5 px, 0.12·blur) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.