harmstyler/contrast-ratio-calculator
最新稳定版本:v1.0.1
Composer 安装命令:
composer require harmstyler/contrast-ratio-calculator
包简介
Calculate contrast ratios of colors.
README 文档
README
Accessibility library that calculates contrast ratios of colors as well as rates the contrast ratio against WCAG standards.
Getting started
- PHP 7.1.x is required
- Install the Contrast Ratio Calculator using Composer (recommended) or manually
Composer Installation
- Get Composer
- Install with
composer require harmstyler/contrast-ratio-calculator - Add the following to your application's main PHP file:
require 'vendor/autoload.php';
Usage
<?php use HarmsTyler\ContrastRatioCalculator\Color; use HarmsTyler\ContrastRatioCalculator\ContrastRatio; use HarmsTyler\ContrastRatioCalculator\WCAGContrastRating; $primaryColor = new Color(); $primaryColor->setHex('#ffffff'); $secondaryColor = new Color(); $secondaryColor->setHex('#000000'); $contrastRatio = new ContrastRatio($primaryColor, $secondaryColor); echo $contrastRatio->getRatio(); // floating decimal point of calculated ratio $rating = new WCAGContrastRating(); echo $rating->rateContrastRatio($contrastRatio); // the WCAGContrast grade, either 'fail', 'aa-large', 'aa', or 'aaa'
Run the tests
./vendor/bin/phpunit tests/
统计信息
- 总下载量: 9.77k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: LGPL-3.0
- 更新时间: 2018-05-16