本文へ移動

Chizu地図

SVGの地図を描き、地域を表示範囲に収め、番号付きの注記や地理クイズを英語と日本語の名前で作れます。

「地図」は、土地や場所を図で表したものです。 名前について(英語)

目次

リファレンス · 表示範囲・形・クイズの道具

nearestWrappedBox関数

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

The copy of a window nearest another one. Travelling from Japan to Hawaii is a short hop east across the date line, and their stored coordinates are at opposite ends of the canvas, so easing between the two as they are stored sweeps the whole earth the wrong way. Sliding the destination onto the nearest copy makes the journey the short one.

インポート

import { nearestWrappedBox } from "@johnmorrisdotca/chizu";

定義

function nearestWrappedBox(from: MapBox, to: MapBox, width: number): MapBox

引数

名前型説明
fromMapBox

The starting window in native map units.

toMapBox

The destination window whose nearest wrapped copy is requested.

widthnumber

The native canvas width or frame width specified by this signature.

戻り値

MapBox

The copy of a window nearest another one. Travelling from Japan to Hawaii is a short hop east across the date line, and their stored coordinates are at opposite ends of the canvas, so easing between the two as they are stored sweeps the whole earth the wrong way. Sliding the destination onto the nearest copy makes the journey the short one.

例

import { nearestWrappedBox } from "@johnmorrisdotca/chizu";

console.log(nearestWrappedBox({ x: -50, y: 0, width: 100, height: 100 }, { x: 900, y: 0, width: 100, height: 100 }, 1000));
// { x: -100, y: 0, width: 100, height: 100 }
{ x: -100, y: 0, width: 100, height: 100 }

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

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

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