本文へ移動

Hata旗

国や地域の旗を読み込み、対応する表示の形を選び、絵ごとの資料・作者・ライセンスを保てます。

「旗(はた)」は、旗を表す日本語です。 名前について(英語)

目次

リファレンス · 軍の旗(軍艦旗・艦首旗・軍旗)

militaryFlag関数

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

A military flag as an SVG string: it has a viewBox and no width or height. frame() and toDataUri() from the main entry take it like any other. A restricted flag (MILITARY_RESTRICTED_IDS) is null unless allowRestricted is true, for a page of history or teaching.

インポート

import { militaryFlag } from "@johnmorrisdotca/hata/military";

定義

function militaryFlag(id: string, options?: { allowRestricted?: boolean; }): Promise<string | null>

引数

名前型説明
idstring

A flag's id, in any case, with or without mil:.

options (省略可){ allowRestricted?: boolean; }

{ allowRestricted: true } to draw a flag shipped for history and education only.

戻り値

Promise<string | null>

The SVG string, loaded when it is asked for (the drawing is a module of its own, so a page carries only the drawings it asks for), or null when the set has no such flag or the flag is restricted and not asked for.

例

import { toDataUri } from "@johnmorrisdotca/hata";
import { militaryFlag } from "@johnmorrisdotca/hata/military";

const ensign = await militaryFlag("mil:gb-white-ensign"); // "<svg …>"
console.log(ensign === null ? null : toDataUri(ensign)?.startsWith("data:image/svg+xml,"));
true

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

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

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