svg定数
リファレンスの説明と例は英語です。見出しと目次は日本語です。
The flag of Fukuoka (福岡県), JP-40, as an SVG string: viewBox 1647 by 1152 (10:7), 616 B. From Wikimedia Commons, "Flag of Fukuoka 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-40";
定義
const svg: string = "<svg data-hata=\"jp-40\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"-823.5 -576 1647 1152\"><path fill=\"#0068b2\" d=\"M-823.5-576h1647V576h-1647z\"/><g transform=\"translate(9 0) scale(38.5)\"><path id=\"hata-jp-40-a\" fill=\"#fff\" d=\"M-2.916-5.294a3 3 0 1 1 5.832 0 8.44 8.44 0 0 1-3.38 4.94 8.7 8.7 0 0 0-.943-1.786A6.44 6.44 0 0 0 .972-5.765a1 1 0 1 0-1.944 0 6.4 6.4 0 0 0 .83 1.947A6.2 6.2 0 0 1-1.55-2.33a8.4 8.4 0 0 1-1.366-2.963\"/><g id=\"hata-jp-40-b\"><use href=\"#hata-jp-40-a\" transform=\"rotate(72)\"/><use href=\"#hata-jp-40-a\" transform=\"rotate(144)\"/></g><use href=\"#hata-jp-40-b\" transform=\"rotate(144)\"/></g></svg>"
例
例 1
import flag from "@johnmorrisdotca/hata/flags/jp-40";
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-40";
console.log(svg.startsWith("<svg"),svg.length);true 616出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。