本文へ移動

Chizu地図

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

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

目次

リファレンス · SVGで地図を描く

ChizuLocalStyle型

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

How one shape of a local map looks, over the look of its kind: colours as drawChizu's colors takes them (hex, a CSS name, rgb(), hsl() or var(--name), anything else ignored), with a second for the dark look, and the classes and custom properties of your own.

インポート

import type { ChizuLocalStyle } from "@johnmorrisdotca/chizu/draw";

定義

type ChizuLocalStyle = {
    fill?: string;
    stroke?: string;
    strokeWidth?: number;
    widthMetres?: number;
    opacity?: number;
    fillOpacity?: number;
    dark?: {
        fill?: string;
        stroke?: string;
    };
    class?: string | readonly string[];
    vars?: Readonly<Record<string, string>>;
};

メンバー

名前型説明
fill (省略可)string | undefined
stroke (省略可)string | undefined
strokeWidth (省略可)number | undefined

The line's width on the screen, in pixels (0 to 40), the same at every zoom.

widthMetres (省略可)number | undefined

Or its width on the ground, in metres: a road 8 m wide is 8 m wide at every zoom (lines and outlines).

opacity (省略可)number | undefined

Opacity of the whole shape, 0 to 1.

fillOpacity (省略可)number | undefined

Opacity of the fill alone, 0 to 1.

dark (省略可){ fill?: string; stroke?: string; } | undefined

The colours when the page is dark; they follow the light ones where missing.

class (省略可)string | readonly string[] | undefined

Classes added to the shape, for your own CSS: letters, digits, - and _.

vars (省略可)Readonly<Record<string, string>> | undefined

Custom properties for your own CSS, { "--seat-rows": "12" }: a name that starts --, and a number with its unit or a colour.

例

import type { ChizuLocalStyle } from "@johnmorrisdotca/chizu/draw";

const stand: ChizuLocalStyle = { fill: "#d9a441", dark: { fill: "#7a5a1c" }, stroke: "#5b3b00", strokeWidth: 2, class: "stand" };
console.log(Object.keys(stand).join(" "));
// fill dark stroke strokeWidth class
fill dark stroke strokeWidth class

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

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

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