Download the PHP package popphp/pop-color without Composer

On this page you can find all versions of the php package popphp/pop-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 pop-color

pop-color

Build Status Coverage Status

Join the chat at https://discord.gg/TZjgT74U7E

Overview

Pop Color is a helpful component to manage different types of color values and conversions. Supported color formats include:

Within the Pop PHP Framework, the pop-css, pop-image and pop-pdf components use this component.

Top

Install

Install pop-color using Composer.

composer require popphp/pop-color

Or, require it in your composer.json file

"require": {
    "popphp/pop-color" : "^2.0.0"
}

Top

Quickstart

Create a color object

The above command will print the default CSS format:

Convert to another color format

Not every color's default string format is CSS — Cmyk and Grayscale default to the PDF-style format above, and Hsv/Hsb (below) default to a delegated rgb(...)/rgba(...) string rather than anything HSV-shaped. Call toCss() when you need guaranteed CSS output regardless of which color class you're holding:

Hex colors with alpha

Hex accepts (and round-trips) the 4-digit #RGBA and 8-digit #RRGGBBAA CSS hex-with-alpha formats, alongside the standard 3- and 6-digit forms. Alpha is exposed as the same 0-1 float used by Rgb/Hsl:

HSV, HSB, and HWB

Hsv and Hsb are the same color model (hue/saturation/value, or hue/saturation/brightness) exposed as two separate classes with the third channel named differently:

Hwb is a native CSS Color 4 format, so — unlike Hsv/Hsb — its default string output is real hwb(...) syntax, with a /-alpha suffix when alpha is set:

Lab, Lch, Oklab, and Oklch

Lab, Lch, Oklab, and Oklch are native CSS Color 4 formats (like Hwb), so their default string output is real lab(...)/lch(...)/oklab(...)/oklch(...) syntax. Unlike every other class in this library, alpha on these four is getAlpha()/setAlpha()/hasAlpha(), not getA()/setA() — Lab and Oklab already use a for their own axis channel, so alpha needed a different name to avoid colliding with it:

Lch and Oklab construct and convert the same way:

Color::parse() also recognizes lab(...), lch(...), oklab(...), and oklch(...) strings:

Accessing Color Properties

Every channel is also readable (and settable) via ArrayAccess or magic property access, as an alternative to the getter/setter methods:

toArray() returns every channel (including alpha, when set) as a plain array:

Parse Color Strings

Color::parse() also recognizes hsv(...), hsb(...), and hwb(...) strings. hwb(...) accepts both the legacy comma-separated form and native CSS Color 4 space-separated syntax with a /-alpha suffix:

Color::parse() also sniffs #hex strings, space-separated CMYK strings, and bare numeric grayscale strings — it dispatches on the shape of the string rather than requiring a format hint:

Error Handling

Color::parse() throws Pop\Color\Color\Exception for any string it doesn't recognize, and every setter throws OutOfRangeException for a value outside its valid range:

Top


All versions of pop-color with dependencies

PHP Build Version
Package Version
Requires php Version >=8.4.0
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 popphp/pop-color contains the following files

Loading the files please wait ...