contrastRatio関数
リファレンスの説明と例は英語です。見出しと目次は日本語です。
The contrast between two colours, from 1 (the same) to 21 (black on white).
インポート
import { contrastRatio } from "@johnmorrisdotca/taisen-brackets/backgrounds";
ほかのエクスポート元: @johnmorrisdotca/taisen-brackets
定義
function contrastRatio(a: Parameters<typeof shared.contrastRatio>[0], b: Parameters<typeof shared.contrastRatio>[1]): number
引数
| 名前 | 型 | 説明 |
|---|---|---|
a | Rgb | The first colour, as red, green and blue. |
b | Rgb | The second colour. |
戻り値
number
The WCAG contrast ratio.
例
import { contrastRatio } from "@johnmorrisdotca/taisen-brackets/backgrounds";
console.log(contrastRatio([255, 255, 255], [0, 0, 0]));21出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。