addBodyfunction
Adds a body to the world and gives it back.
Every export of every entry point, each with its own page. This page keeps the addresses the old one-page reference had.
@johnmorrisdotca/karakuri/physicsaddBodyfunctionAdds a body to the world and gives it back.
addLinkfunctionLinks two nodes at their present distance (or at length) and gives back the link's index.
addNodefunctionAdds a node and gives back its index.
addRopefunctionLays a rope of pieces links from (ax, ay) to (bx, by): the first node is pinned and the last is the node end if one is given (its place is moved to the rope's end), and the nodes between are light.
BodytypeA rigid body.
BodySpectypeWhat createBody is told.
BodyTypetypeHow a body moves: dynamic by forces and contacts, kinematic only as the game sets it (it pushes, and is not pushed), static not at all.
capsulesAlongfunctionA capsule chain for a drawn line: one capsule between each pair of neighbouring points.
CapsuleShapetypeA thick segment, from (ax, ay) to (bx, by) with a radius, placed in the body's own frame.
CircleShapetypeA disc, placed in the body's own frame (its origin is the body's centre of mass for a dynamic body).
clampfunctionvalue held between low and high.
closestBetweenSegmentsfunctionThe nearest points of two segments: where on each, and how far apart they are.
closestOnSegmentfunctionThe point on the segment a to b nearest to (px, py), and how far along the segment it is (0 to 1).
ContacttypeOne contact between two shapes: the normal points from a towards b.
contactsBetweenfunctionThe contacts between two bodies whose shapes are within margin of each other.
countOffunctionHow many particles of a kind.
createBodyfunctionMakes a body from a spec.
createFluidfunctionMakes a liquid with no particles.
createRigfunctionMakes an empty rig.
createWorldfunctionMakes a world.
DisctypeThe round bodies the particles must not enter (a character, a coin): centre and radius.
distancefunctionThe distance between two points.
distanceSquaredfunctionThe squared distance between two points, which needs no square root.
distanceToSegmentfunctionHow far (px, py) is from the segment a to b.
fillRectfunctionFills the rectangle from (x, y) to (x + w, y + h) with particles of one kind on a grid a little looser than they settle.
FluidtypeThe liquid: its particles and how it behaves.
FluidKindtypeWhat a particle is made of.
fluidNumbersfunctionEvery number of the liquid's particles, for hashing it (kinds as 0, 1, 2).
gapfunctionThe gap between two bodies: the smallest gap of any pair of their shapes (negative when they overlap).
hashNumbersfunctionA 32-bit FNV-1a hash of a list of numbers, taken over the bits of each as a 64-bit float.
isSettledfunctionWhether every dynamic body in the world is slower than speed (units a second) and is hardly turning.
lengthfunctionThe length of (x, y).
linkCrossedfunctionThe index of the first live link that the swipe from (x1, y1) to (x2, y2) crosses, or -1.
nearestTofunctionThe nearest distance from a particle of a kind to a disc's surface (negative when it is inside), or Infinity when there is none.
nodeSpeedfunctionThe speed of a node in units a second at a step of dt.
ParticletypeOne particle.
pointInPolygonfunctionWhether (px, py) is inside the polygon (an even-odd test over its vertices, in order).
refreshShapesfunctionRecomputes a body's shapes in world places from its position and angle.
RigtypeA set of nodes and links, with the fixed shapes the round nodes rest on.
RigLinktypeA link that keeps two nodes length apart (a rope pulls but does not push: slack links only pull).
RigNodetypeA point of a chain.
rigNumbersfunctionEvery number of the rig's nodes, for hashing it.
segmentsIntersectfunctionWhether the segments a1 to a2 and b1 to b2 cross or touch.
ShapetypeA shape of a body.
STEPconstantThe length of the fixed step every game runs at, in seconds.
stepFluidfunctionAdvances the liquid by one step of dt seconds.
stepRigfunctionAdvances the rig by one step of dt seconds.
stepWorldfunctionAdvances the world by one fixed step (STEP seconds) in substeps smaller ones.
unitfunctionThe unit vector of (x, y), or (0, 0) for a zero vector.
VectypeA point or a vector in the plane.
WorldtypeThe world: its gravity (down is +y, in units a second squared), its bodies in the order they were added, and how hard it works.
worldNumbersfunctionEvery number of a world's bodies' state, for hashing it: a determinism test compares these bit for bit.
WorldShapetypeA shape as the world sees it now: a circle as (ax, ay, r) with a = b, a capsule with its two ends.
@johnmorrisdotca/karakuri/levelsGRID_ESCAPE_LEVELSconstantThe levels, from easy to hard by their fewest moves.
GridEscapeLeveltypeOne level: its board and its proved fewest moves.
gridPuzzleOffunctionThe board of a level, read.
NUTS_AND_BOLTS_LEVELSconstantThe levels, with more plates and more screws each time.
PIN_RESCUE_LEVELSconstantThe levels, each with more pins to choose between and more ways to lose.
PinRescueEntrytypeA level, the pins that win it in order (by index in pins), and pins that lose it in order.
ROPE_CUT_LEVELSconstantThe levels.
RopeCutEntrytypeA level and the cuts that win it, in order: the step to cut at, which rope, which link of it.
SAVE_THE_CHARACTER_LEVELSconstantThe levels.
SaveEntrytypeA level and the stroke that wins it (points, drawn in order) and a stroke that loses it.
STORIESconstantThe stories, one to a level.
STRETCH_GRABBER_LEVELSconstantThe levels.
StretchGrabberEntrytypeA level, the waypoints of one way to win it, and of one way to lose it.
TUBE_SORT_LEVELSconstantThe levels, each with more colours and more tubes than the one before.
@johnmorrisdotca/karakuri/playControllertypeOne level of one game, played.
createControllerfunctionMakes a controller for level level (from 1) of a game; a level out of range is held to the nearest.
defaultThemefunctionThe theme without a page: the light one, for a drawing made where there is no style to read (a test, a server).
GameInfotypeWhat a game of the package is, for a chooser.
InfotypeWhat the player reads in the bar above the board.
KARAKURI_GAME_IDSconstantThe ids of the games, in the order the package lists them (kebab case, the same in every address and attribute).
KARAKURI_GAMESconstantTHE GAMES of the package, by id.
KARAKURI_STYLEconstantTHE STYLE the player wears: the colours as custom properties on .karakuri (light, and dark when the page asks for it by prefers-color-scheme or by data-theme="dark" on the root), the layout of the bar, the play area and the buttons, and the one rule that matters for games played with fingers: nothing on the board can be selected, dragged or double-tapped, and the play area stops the page scrolling under a finger only for the games that read a finger's whole path.
KARAKURI_THEMESconstantThe look the games draw with, as custom properties, so a page can change any of them.
KarakuriGametypeThe id of a game of the package.
KarakuriMounttypeThe native handle, including its controller and focused keyboard canvas.
mountKarakurifunctionPlays one game of the package in host: a canvas that scales to the box it is given, the pointer (finger or mouse) wired to the game, a fixed-step loop that runs only while something moves, and (with ui: "full") the bar, the buttons and the card that says how a level ended.
MountOptionstypeInitial native controller, level, layout, keyboard, clock and host callbacks.
PointtypeA place in a game's own world, in its own units (not pixels).
readThemefunctionReads the theme a game draws with from an element's computed style: each colour is --kk-<name>, with the light or the dark default beneath.
SaytypeA line of words to be said in the player's language: a key of KARAKURI_STRINGS and the values for its {name}s.
StatustypeHow a level stands: still being played, won, or lost.
StatusEventtypeWhat a status callback is given.
ThemetypeThe colours and sizes a game draws with, read from the page's custom properties (--kk-*) so that it follows light, dark and the family's cloths.
@johnmorrisdotca/karakuri/elementdefineBoardfunctionDefines the board or a subclass under a custom tag.
KARAKURI_EMBED_OPTION_KEYSconstantNative mounted options, checked against the embed builder.
KarakuriBoardclassA reflected puzzle-game element with a preserved native controller.
KarakuriElementOptionstypeFull native host options; attributes take priority over starting choices.
@johnmorrisdotca/karakuri/element/definedefineBoardfunctionDefines the board or a subclass under a custom tag.
KARAKURI_EMBED_OPTION_KEYSconstantNative mounted options, checked against the embed builder.
KarakuriBoardclassA reflected puzzle-game element with a preserved native controller.
KarakuriElementOptionstypeFull native host options; attributes take priority over starting choices.
@johnmorrisdotca/karakurichoiceStorynamespaceControllertypeOne level of one game, played.
GameInfotypeWhat a game of the package is, for a chooser.
gridEscapenamespaceInfotypeWhat the player reads in the bar above the board.
KARAKURI_STRINGSconstantNative player, keyboard, game and story words in English and Japanese.
KarakuriLanguagetypeThe native English or Japanese puzzle-player language.
nutsAndBoltsnamespacepinRescuenamespacePointtypeA place in a game's own world, in its own units (not pixels).
ropeCutnamespacesaveTheCharacternamespacesayfunctionThe words for key in lang, with each {name} filled from values; English when the language has none; the key itself when nobody has.
SaytypeA line of words to be said in the player's language: a key of KARAKURI_STRINGS and the values for its {name}s.
StatustypeHow a level stands: still being played, won, or lost.
stretchGrabbernamespaceThemetypeThe colours and sizes a game draws with, read from the page's custom properties (--kk-*) so that it follows light, dark and the family's cloths.
tubeSortnamespaceVERSIONconstantThe package's version, kept equal to package.json's by a test.
wordKeyfunctionThe key a game's words are kept under: its id with underscores for hyphens (game_tube_sort, rules_tube_sort).