本文へ移動

Hata旗

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

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

目次

リファレンス · 国際機関の旗

organisationFlag関数

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

An organisation's flag as an SVG string, the same kind of string a country's module holds: it has a viewBox and no width or height. frame() and toDataUri() from the main entry take it like any other. The entry holds the drawing of the European Union (the flag drawn for this package), so this answers at once; the bodies taken from Wikimedia Commons are drawings of their own, loaded on demand: loadOrganisationFlag gives any of them.

インポート

import { organisationFlag } from "@johnmorrisdotca/hata/organisations";

定義

function organisationFlag(id: string): string | null

引数

名前型説明
idstring

An organisation's id, in any case, with or without org: ("org:eu", "EU").

戻り値

string | null

The SVG string, or null when the id has no flag here or its drawing is not held in this entry (see loadOrganisationFlag).

例

import { frame } from "@johnmorrisdotca/hata";
import { organisationFlag } from "@johnmorrisdotca/hata/organisations";

const european = organisationFlag("org:eu"); // "<svg …>"
console.log(european === null ? null : frame(european, { shape: "round", label: "European Union" }));
console.log(organisationFlag("org:xx"));     // null
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" role="img" aria-label="European Union"><title>European Union</title><defs><clipPath id="hata-round-638uto"><circle cx="256" cy="256" r="256"/></clipPath></defs><g clip-path="url(#hata-round-638uto)"><circle cx="256" cy="256" r="256" fill="#e6e6e6"/><svg data-hata-org="eu" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 900 600" x="43" y="114" width="426.01" height="284.01" preserveAspectRatio="xMidYMid meet"><defs><path id="org-eu-star" fill="#fc0" d="M0 -33.33L7.48 -10.3L31.7 -10.3L12.11 3.93L19.59 26.97L0 12.73L-19.59 26.97L-12.11 3.93L-31.7 -10.3L-7.48 -10.3z"/></defs><path fill="#039" d="M0 0h900v600H0z"/><use href="#org-eu-star" x="450" y="100"/><use href="#org-eu-star" x="550" y="126.79"/><use href="#org-eu-star" x="623.21" y="200"/><use href="#org-eu-star" x="650" y="300"/><use href="#org-eu-star" x="623.21" y="400"/><use href="#org-eu-star" x="550" y="473.21"/><use href="#org-eu-star" x="450" y="500"/><use href="#org-eu-star" x="350" y="473.21"/><use href="#org-eu-star" x="276.79" y="400"/><use href="#org-eu-star" x="250" y="300"/><use href="#org-eu-star" x="276.79" y="200"/><use href="#org-eu-star" x="350" y="126.79"/></svg></g></svg>
null

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

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

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