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

nearestTofunction

The nearest distance from a particle of a kind to a disc's surface (negative when it is inside), or Infinity when there is none.

Import it

import { nearestTo } from "@johnmorrisdotca/karakuri/physics";

Definition

function nearestTo(fluid: Fluid, kind: FluidKind, disc: Disc): number

Parameters

NameTypeDescription
fluidFluid

The mutable native particle fluid.

kindFluidKind

The native water, lava or stone particle kind.

discDisc

The native disc whose surface distance is measured.

Returns

number

The nearest surface gap for the requested particle kind, or Infinity when no such particle exists.

Examples

import { createFluid, fillRect, nearestTo } from "@johnmorrisdotca/karakuri/physics";

const fluid=createFluid({radius:2,gravity:0,iterations:1,reacts:false});
fillRect(fluid,"water",0,0,8,8);
console.log(nearestTo(fluid,"water",{x:0,y:0,r:1}));
-0.1715728752538097

What it prints (run when this page was built)

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