Download the PHP package avadim/ace-colors without Composer

On this page you can find all versions of the php package avadim/ace-colors. 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 ace-colors

AceColors

tests

A set of helpers for converting and manipulating colors. Converts between HEX, RGB(A) and HSL(A) in any direction, and lets you lighten, darken, saturate, mix and invert a color.

Requires PHP 7.4 or above and has no runtime dependencies.

Install

The package is not published on Packagist yet, so add the repository explicitly:

Composer is not required — the package ships its own autoloader:

Sample usage

If the '#' prefix was present in the constructor, it is kept in the hex output; otherwise it is omitted. Use useSharp(true|false) to control that explicitly. Casting the object to a string always yields the hex code with a '#'.

Input formats

Correct input HEX-strings

The first character '#' can be omitted, so 'ff9966' is equivalent of '#ff9966'

Correct RGB or RGBA strings

Correct HSL or HSLA strings

Correct input RGB-arrays are

You can use uppercase indexes, ex. ['R' => 255, 'G' => 0, 'B' => 51]

Also, RGB-arrays can be with missed indexes:

Correct input HSL-arrays are

You can use uppercase indexes, ex. ['H' => 120, 'S' => 1, 'L' => 0.5]

A positional array is always read as RGB, because [120, 1, 0.5] is a valid RGB triplet too. To pass a positional HSL array use setHsl([120, 1, 0.5]).

Methods

Set the whole color

Set color components

Values accept plain numbers, percent strings ('50%') and, for the RGB channels, the '#ff' notation. The same channels are available as magic properties, with short aliases:

Get color in different formats

Static converters

A converter whose result name has no a drops the alpha channel: hexToRgb() returns ['r', 'g', 'b'], while hexToRgba() also returns 'a'. When the input carries no alpha, the static converters return 'a' => null, whereas getRgba() on an instance returns 1.0.

Manipulations

These modify the color in place and return $this, so they can be chained:

The amounts accept percents (50, '50%') and fractions (0.5) alike.

Methods returning a new object

The originals are left untouched:

Other

Key case of the returned arrays

By default the returned arrays use lowercase keys. If your storage expects uppercase ones, switch it globally:

Input is accepted in either case regardless of this setting, and methods returning strings are not affected. The setting is global for the process, so a long-running worker should restore it itself. getKeyCase() returns the current value.

Tests

License

MIT


All versions of ace-colors with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
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 avadim/ace-colors contains the following files

Loading the files please wait ...