定制 harmstyler/contrast-ratio-calculator 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

  1. PHP 7.1.x is required
  2. Install the Contrast Ratio Calculator using Composer (recommended) or manually

Composer Installation

  1. Get Composer
  2. Install with composer require harmstyler/contrast-ratio-calculator
  3. 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

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: LGPL-3.0
  • 更新时间: 2018-05-16