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 · Flag source and framing metadata

FlagColourtype

One colour of a flag, measured from the shipped drawing (the flag's own, never a frame or a crop) drawn 1200 pixels wide: every pixel counted by its exact colour, the smoothed edges and the steps of a gradient given to the nearest colour that covers at least 0.1% of the flag (pnpm data:colours, scripts/colours.mjs).

Import it

import type { FlagColour } from "@johnmorrisdotca/hata/manifest";

Also exported from: @johnmorrisdotca/hata/search

Definition

interface FlagColour {
    hex: string;
    share: number;
    name: ColourName;
}

Members

NameTypeDescription
hexstring

The colour as the drawing has it, #rrggbb in lower case.

sharenumber

The share of the flag's drawn area it covers, from 0 to 1, to four decimals.

nameColourName

The nearest name of the closed list: see ColourName.

Examples

import { manifest, type FlagColour } from "@johnmorrisdotca/hata/manifest";

const japan: FlagColour[] = manifest("JP")?.colours ?? [];
console.log(japan); // [{ hex: "#ffffff", share: 0.8116, name: "white" }, { hex: "#bc002d", share: 0.1884, name: "red" }]
[
  { hex: '#ffffff', share: 0.8116, name: 'white' },
  { hex: '#bc002d', share: 0.1884, name: 'red' }
]

What it prints (run when this page was built)

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