Download the PHP package aristath/ari-color without Composer

On this page you can find all versions of the php package aristath/ari-color. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package ari-color

ariColor

A PHP library for color manipulation in themes and plugins

Build Status codecov.io License

ariColor is a PHP library that will hopefully help WordPress theme developers do their job easier and more effectively.

Installation

It does not provide you with methods like lighten(), darken() etc. Instead, what it does is give you the ability to create these yourself with extreme ease by giving you all the properties of a color at hand, and allowing you to manipulate them however you see fit.

Example:

First, let's create our color object:

If you don't like using that method you can write your own proxy function:

Notice that we used auto as the mode. If you use auto or completely omit the 2nd argument, ariColor will auto-detect it for you. You can use rgb, rgba, hsl, hsla, or even arrays as colors.

Then you can use it like this:

Say you want to get the values for red, green, blue:

Or you want to get the hue, saturation, lightness or even luminance of your color:

Scenario 1:

You have an option where users can define the background color for their <body>. In order to make sure the text is always readable, you can either give them a 2nd option to set the text color, or auto-calculate it for readability.

Example function that given a background color decides if we're going to use white/black text color:

Usage:

Easy, right? What we did above is simply check the luminance of the background color, and then if the luminance is greater than 127 we return black, otherwise we return white.

Scenario 2:

We have a HEX color, and we want to get the same color as rgba, with an opacity of 0.7:

or you could write it shorter like this:

or the same thing like this:

The choice is yours and you can manipulate colors in any way you want.

Properies list:

Methods:

newColor

Used to create a new object. Example:

The newColor method has 2 arguments:

  1. $color: can accept any color value (see below for examples)
  2. $mode: the color mode. If undefined will be auto-detected.

Some example of acceptable formats for the color used in the 1st argument on the method:

And more! This way you can use the saved values from all known frameworks.

getNew

Used if we want to create a new object identical to the one we already have, but changing one of its properties.

The getNew method has 2 arguments:

  1. $property: can accept any of the properties listed above
  2. $value: the new value of the property.

Example 1: Darken a color by 10%

Or you could write the above simpler like this by combining 2 steps:

Example 2: Remove any traces of green from an HSL color

toCSS

Returns a CSS-formatted color value.

The toCSS has a single argument:

  1. $mode: can accept any of the values listed below (defaults to hex if undefined)

Example:

Color sanitization:

All colors are sanitized inside the class so you could easily write a proxy function that will always return a sanitized color like this:

You can even use a function like this one as a sanitize_callback in a customizer control :)

Testing


All versions of ari-color with dependencies

PHP Build Version
Package Version
Requires php Version >=5.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package aristath/ari-color contains the following files

Loading the files please wait ....