Skip to the content

Hata旗

Load a native country or region flag, choose supported framing and keep each drawing’s source, author and licence.

Hata (旗) is Japanese for a flag. About the name

Contents

Reference · Flags of international organisations

organisationFlagfunction

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 it

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

Definition

function organisationFlag(id: string): string | null

Parameters

NameTypeDescription
idstring

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

Returns

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).

Examples

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

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/hata 1.31.0.