本文へ移動

Karakuriからくり

8つの標準のパズルで遊び、探索や再現できる物理を使い、ポインターやキーボードで操作する盤を表示できます。

「からくり」は、仕組みや工夫した装置を表す言葉です。 名前について(英語)

目次

リファレンス · 再現できる2D物理

linkCrossed関数

リファレンスの説明と例は英語です。見出しと目次は日本語です。

The index of the first live link that the swipe from (x1, y1) to (x2, y2) crosses, or -1. A swipe cuts one link: the nearest to its start.

インポート

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

定義

function linkCrossed(rig: Rig, x1: number, y1: number, x2: number, y2: number, among?: readonly number[]): number

引数

名前型説明
rigRig

The mutable native rope nodes, constraints and static geometry.

x1number

The swipe’s starting horizontal coordinate.

y1number

The swipe’s starting vertical coordinate.

x2number

The swipe’s ending horizontal coordinate.

y2number

The swipe’s ending vertical coordinate.

among (省略可)readonly number[] | undefined

Optional native link indices to test instead of the whole rig.

戻り値

number

The first crossed alive link’s native index, or -1 when the swipe crosses none.

例

import { addRope, createRig, linkCrossed } from "@johnmorrisdotca/karakuri/physics";

const rig=createRig({gravity:0,iterations:1});
addRope(rig,0,0,10,0,2);
console.log(linkCrossed(rig,5,-5,5,5));
0

出力(このページを作ったときに実行した結果)

ソースを見るGitHub で編集@johnmorrisdotca/karakuri 0.2.1 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。