定制 ottawadeveloper/coloranalyzer 二次开发

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

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

ottawadeveloper/coloranalyzer

Composer 安装命令:

composer require ottawadeveloper/coloranalyzer

包简介

Provides WCAG information about CSS colors.

README 文档

README

This project provides tools to analyze colors from CSS code to see which combinations comply with the W3C's recommended contrast ratio.

As this is a personal project, I've taken the opportunity to make some elements very robust (far robust than they probably need to be) so that it is very extendable by other solutions.

Color Support

Out of the box, this library provides support for:

  • 2-digit hex codes that represent a shade of grey
  • 3-digit hex codes that represent a web-safe color
  • 6-digit hex code colors
  • 8-digit hex codes that represent a color with alpha value
  • Official CSS color keywords
  • Valid calls to rgb(), rgba(), hsl() and hsla()

Other applications who leverage this library can extend the default supported methods by providing an object that implements the ColorProcessor interface and adding it to the ColorFactory.

Reporting Support

Out of the box, this library provides a reporting functionality that allows other applications to define the columns they want to see in a report, as well as a separate formatter. Reports are generated by pairing each color provided with each other color, and then running the report components for each pair. Out of the box, the following columns are supported:

  • ColorTextReport: Display the name of the color, using an instance of ColorProcessor to display the color. Note that you have to add it twice to the report: once for the foreground, and once for the background.
  • LuminosityContrastReport: Display the luminosity constrast ratio (value between 1 and 21) between the two colors.
  • Wcag2ComplianceReport: Displays whether the colors are compliant with either the AA criteria or AAA criteria.

You can add your own reporting columns by implementing the ReportComponent interface and adding an instance of it to your report.

Blending Support

This library provides support for blending two colors together, and allowing other applications to choose the strategy. By default, the alpha composite method is used (with support for transparent backgrounds as well). Blending is automatically applied to non-opaque colors when calculating the luminosity contrast.

To change the blending strategy, you can implement the ColorBlender interface, and then pass the implementation to the ColorFactory. Only one blending strategy can be used.

Usage

See example-report.php for an example of generating a report.

License

This project is provided under the MIT license, meaning that you can reuse it as you would like, as long as you keep the LICENSE.txt file with it.

统计信息

  • 总下载量: 12
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-02-05

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固