本文へ移動

Hata旗

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

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

目次

リファレンス · 色で旗を探す

coloursOf関数

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

A flag's colours, the one that covers most of it first: each an exact hex as the drawing has it, the share of the flag it covers and its name. Measured from the flag's own drawing, never from a frame or a crop (manifest(code).colours is the same list).

インポート

import { coloursOf } from "@johnmorrisdotca/hata/search";

定義

function coloursOf(code: string, options?: { variant?: string; }): readonly FlagColour[]

引数

名前型説明
codestring

A flag's code in any case: "JP", "jp-13", "CA_ON"; a former country by its code or one of its aliases.

options (省略可){ variant?: string; } | undefined

variant: the id of another of the place's flags (variantsOf(code)), such as Afghanistan's "de-facto".

戻り値

readonly FlagColour[]

The colours, frozen; an empty list when the code has no flag here, or no such variant.

例

import { coloursOf } from "@johnmorrisdotca/hata/search";

console.log(coloursOf("JP"));                          // [{ hex: "#ffffff", share: 0.8116, name: "white" }, { hex: "#bc002d", share: 0.1884, name: "red" }]
console.log(coloursOf("FR").map((one) => one.name));   // ["blue", "red", "white"]
console.log(coloursOf("AF", { variant: "de-facto" })); // the Taliban's flag: white and black
console.log(coloursOf("XX"));                          // []
[
  { hex: '#ffffff', share: 0.8116, name: 'white' },
  { hex: '#bc002d', share: 0.1884, name: 'red' }
]
[ 'blue', 'red', 'white' ]
[
  { hex: '#ffffff', share: 0.8952, name: 'white' },
  { hex: '#000000', share: 0.1048, name: 'black' }
]
[]

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

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

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