Skip to the content

Karakuriからくり

Play eight native puzzles, run bounded searches, step deterministic physics and mount a canvas player controlled by pointer or keyboard.

Karakuri is the Japanese word からくり for a mechanism or ingenious device. About the name

Contents

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

NameTypeDescription
fluidFluid

The mutable native particle fluid.

kindFluidKind

The native water, lava or stone particle kind.

xnumber

The horizontal coordinate or vector component in native units.

ynumber

The vertical coordinate or vector component in native units.

wnumber

The fill rectangle width in native units.

hnumber

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));
3

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/karakuri 0.2.1.