本文へ移動

Tsunagi繋ぎ

同じ印の2つを別々の線で結び、盤を埋めます。収録された問題やシード付きの問題で遊べます。

「つなぎ」は、物をつなぐことを表す言葉です。 名前について(英語)

目次

リファレンス · SVGの盤

TsunagiGeometry型

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

The board dimensions, cell centres and playable-cell mapping used by SVG and pointer input.

インポート

import type { TsunagiGeometry } from "@johnmorrisdotca/tsunagi/draw";

定義

type TsunagiGeometry = {
    size: number;
    hex: boolean;
    ring: number;
    coordinates: boolean;
    side: number;
    paper: {
        x: number;
        y: number;
        width: number;
        height: number;
    };
    centre: (cell: number) => TsunagiPoint;
    onBoard: (cell: number) => boolean;
};

メンバー

名前型説明
sizenumber
hexboolean
ringnumber

One ghost cell all round, on a board that wraps.

coordinatesboolean

Whether the drawing has the board's coordinates down its sides.

sidenumber

The drawing's width and height, the same, in its units.

paper{ x: number; y: number; width: number; height: number; }

Where the playing surface starts and how far it goes, inside the frame and the coordinates.

centre(cell: number) => TsunagiPoint

The middle of a cell, in the drawing; for a hexagon, only of the cells on the board.

onBoard(cell: number) => boolean

Whether a cell is on the board: every one of a square, only the hexagon's own of a honeycomb.

例

import { TSUNAGI_4 } from "@johnmorrisdotca/tsunagi/levels-4";
import { decodeLayout } from "@johnmorrisdotca/tsunagi";
import { tsunagiGeometry } from "@johnmorrisdotca/tsunagi/draw";
import type { TsunagiGeometry } from "@johnmorrisdotca/tsunagi/draw";

const givens = TSUNAGI_4[0][0];
const layout = decodeLayout(givens,4)!;
const geometry = tsunagiGeometry(layout);
const value: TsunagiGeometry = geometry;
console.log(value);
{
  size: 4,
  hex: false,
  ring: 0,
  coordinates: false,
  side: 428,
  paper: { x: 14, y: 14, width: 400, height: 400 },
  centre: [Function: centre],
  onBoard: [Function: onBoard]
}

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

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

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