aspectOf関数
リファレンスの説明と例は英語です。見出しと目次は日本語です。
The aspect ratio of a flag, width over height, read from its SVG's viewBox: 1.5 for Japan's 2:3, 2 for Canada's 1:2, 1.9 for the United States' 10:19.
インポート
import { aspectOf } from "@johnmorrisdotca/hata";
定義
function aspectOf(svg: string): number | null
引数
| 名前 | 型 | 説明 |
|---|---|---|
svg | string | A flag's SVG string, from |
戻り値
number | null
The width divided by the height, or null when the string is not an SVG with a viewBox.
例
import { aspectOf } from "@johnmorrisdotca/hata";
import japan from "@johnmorrisdotca/hata/flags/jp";
console.log(aspectOf(japan)); // 1.5
console.log(aspectOf("not an svg")); // null1.5
null出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。