Reference · Flags by their colours
coloursOffunction
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 it
import { coloursOf } from "@johnmorrisdotca/hata/search";
Definition
function coloursOf(code: string, options?: { variant?: string; }): readonly FlagColour[]
Parameters
| Name | Type | Description |
|---|---|---|
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 (optional) | { variant?: string; } | undefined |
|
Returns
readonly FlagColour[]
The colours, frozen; an empty list when the code has no flag here, or no such variant.
Examples
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' }
]
[]What it prints (run when this page was built)