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[]
引数
| 名前 | 型 | 説明 |
|---|---|---|
code | string | 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 |
|
戻り値
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' }
]
[]出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。