File: wcag-example.js

Recommend this page to a friend!
  Classes of Andrew Collington  >  PHP WCAG Color Compliance  >  wcag-example.js  >  Download  
File: wcag-example.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: PHP WCAG Color Compliance
Get the contrast ratio between two colors for WCAG
Author: By
Last change:
Date: 2 years ago
Size: 1,384 bytes
 

Contents

Class file image Download
const { wcag } = require('./wcag');

console.log('===== Accessibility checks =====');
console.log(wcag.accessibility('013035', 'F2C75C'));
console.log(wcag.accessibility('1E428A', 'C284A3'));
console.log(wcag.accessibility('D6D2C4', 'FFE900'));
console.log(wcag.accessibility('FF9966', '000000'));
console.log(wcag.accessibility('FFFFFF', [0, 0, 0]));
console.log(wcag.accessibility([255, 255, 255], '#000'));

console.log('===== Luminance =====');
console.log(wcag.luminance('013035'));
console.log(wcag.luminance('1E428A'));
console.log(wcag.luminance('D6D2C4'));
console.log(wcag.luminance('FF9966'));
console.log(wcag.luminance('FFFFFF'));
console.log(wcag.luminance('000000'));

console.log('===== Contrast ratio =====');
console.log(wcag.contrastRatio('013035', 'F2C75C'));
console.log(wcag.contrastRatio('1E428A', 'C284A3'));
console.log(wcag.contrastRatio('D6D2C4', 'FFE900'));
console.log(wcag.contrastRatio('FF9966', '000000'));
console.log(wcag.contrastRatio('FFFFFF', [0, 0, 0]));
console.log(wcag.contrastRatio([255, 255, 255], '#000'));

console.log('===== Hex to RGB =====');
console.log(wcag.hex2rgb('#013035'));
console.log(wcag.hex2rgb('1E428A'));
console.log(wcag.hex2rgb('#D6D2C4'));
console.log(wcag.hex2rgb('FF9966'));
console.log(wcag.hex2rgb('#FFF'));
console.log(wcag.hex2rgb('#000'));
console.log(wcag.hex2rgb('FFFFFF'));
console.log(wcag.hex2rgb('000000'));
For more information send a message to info at phpclasses dot org.