Reference · Deterministic 2D physics
fillRectfunction
Fills the rectangle from (x, y) to (x + w, y + h) with particles of one kind on a grid a little looser than they settle.
Import it
import { fillRect } from "@johnmorrisdotca/karakuri/physics";
Definition
function fillRect(fluid: Fluid, kind: FluidKind, x: number, y: number, w: number, h: number): number
Parameters
| Name | Type | Description |
|---|---|---|
fluid | Fluid | The mutable native particle fluid. |
kind | FluidKind | The native water, lava or stone particle kind. |
x | number | The horizontal coordinate or vector component in native units. |
y | number | The vertical coordinate or vector component in native units. |
w | number | The fill rectangle width in native units. |
h | number | The fill rectangle height in native units. |
Returns
number
Fills the rectangle from (x, y) to (x + w, y + h) with particles of one kind on a grid a little looser than they settle.
Examples
import { createFluid, fillRect } from "@johnmorrisdotca/karakuri/physics";
const fluid=createFluid({radius:2,gravity:0,iterations:1,reacts:false});
fillRect(fluid,"water",0,0,8,8);
console.log(fillRect(fluid,"water",10,0,8,8));3What it prints (run when this page was built)