svg定数
リファレンスの説明と例は英語です。見出しと目次は日本語です。
The flag of Hyōgo (兵庫県), JP-28, as an SVG string: viewBox 182.27 by 128.15 (1.422:1), 1.1 KB. From Wikimedia Commons, "Flag of Hyogo Prefecture.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/jp-28";
定義
const svg: string = "<svg data-hata=\"jp-28\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 182.27 128.15\"><g stroke-linecap=\"round\" stroke-linejoin=\"round\"><path fill=\"#01a0c7\" d=\"M0 128.15h182.27V0H0z\"/><g fill=\"#fff\" stroke-width=\".1\"><path d=\"M5.59 26.51c35.87 3.15 60.06-5.2 92.78-12.03 30.94-6.45 47.2-7.73 78 12.84-30.3-5.78-45.26-1.83-87.34 6.48-16.4 3.24-28.9 7.24-40.5 7.9-14.86.85-34.63-7.15-42.94-15.19m.67 71.71c35.15 6.82 60.07-2.68 92.79-9.5 30.94-6.45 41.9-10.37 78 13.73-27.15-6.79-56.09-2.17-86.96 6.54-5.8 1.64-26.48 6.26-40.89 6.26-12.78 0-34.62-8.99-42.94-17.03\"/><path d=\"M131.65 34.12c-14.74-.02-29.38 3.9-44.89 6.95-32.09 6.31-50.43 13.03-80.5 5.36 5.6 10.78 24.4 18.94 42.12 17.93l2.4-.16 5.12 11.37c-12.38 2.3-24.62 3.18-50.32 1.5 9.16 8.11 32.2 16.2 49.91 15.19 11.6-.66 16.63-2.13 34.24-6.04 45.88-10.18 57.23-12.24 86.65-7.35-13.82-14.32-29.94-17.8-46.7-17.03l-5.2-11.55c22.08-4.17 30.85-3.64 52.57.5-15.85-12.7-30.67-16.65-45.4-16.67m-26.3 20.13 4.53 10.06c-7.98 1.46-15.97 3.3-23.8 4.84-4.1.8-7.76 1.58-11.12 2.32l-4.46-9.91a527 527 0 0 0 19.9-4.04z\"/></g></g></svg>"
例
例 1
import flag from "@johnmorrisdotca/hata/flags/jp-28";
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/jp-28";
console.log(svg.startsWith("<svg"),svg.length);true 1076出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。