svg定数
リファレンスの説明と例は英語です。見出しと目次は日本語です。
The flag of Barbados (バルバドス), BB, as an SVG string: viewBox 24000 by 16000 (3:2), 561 B. From Wikimedia Commons, "Flag of Barbados.svg" (public domain); the /manifest entry gives its author, licence and why it was chosen. It has a viewBox and no width or height, so it fills the box it is put in at its own aspect ratio.
インポート
import { svg } from "@johnmorrisdotca/hata/flags/bb";
定義
const svg: string = "<svg data-hata=\"bb\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24000 16000\"><path fill=\"#1f367c\" d=\"M0 0h24000v16000H0z\"/><path fill=\"#f3b100\" d=\"M8000 0h8000v16000H8000z\"/><path id=\"hata-bb-a\" fill=\"#000\" d=\"M12000 4124c-260 709-525 1447-1092 2012 176-58 484-110 682-105v2982l-842 125c-30-3-40-50-40-114-81-926-300-1704-552-2509-18-110-337-530-91-456 30 4 359 138 307 74a3185 3185 0 0 0-1739-897c-56-14-89 14-39 79 844 1299 1550 2832 1544 4651 328 0 1123-194 1452-194v2104h415l95-5876z\"/><use href=\"#hata-bb-a\" transform=\"matrix(-1 0 0 1 24000 0)\"/></svg>"
例
例 1
import flag from "@johnmorrisdotca/hata/flags/bb";
const host=document.createElement("div");
host.innerHTML = flag; // or toDataUri(flag) from "@johnmorrisdotca/hata" for an <img src>
console.log(host.querySelector("svg")?.getAttribute("viewBox"));例 2
import { svg } from "@johnmorrisdotca/hata/flags/bb";
console.log(svg.startsWith("<svg"),svg.length);true 561出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。