2017 © Pedro Peláez
 

library php-hexer

A package to adjust brightness from a hex colorcode

image

lasserafn/php-hexer

A package to adjust brightness from a hex colorcode

  • Monday, August 14, 2017
  • by lasserafn
  • Repository
  • 1 Watchers
  • 5 Stars
  • 16 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 23 % Grown

The README.md

HEX color modifier — brightness, conversion and more.

Ever wanted to lighten or darken a hex in PHP? This package will allow you to. It's easy to use, fully tested and is very lightweight., (*1)

+ Added the ability to convert to RGB, (*2)

Build Status Coverage StyleCI Status Total Downloads Latest Stable Version License , (*3)

Installation

You just require using composer and you're good to go!, (*4)

composer require lasserafn/php-hexer

Usage

As with installation, usage is quite simple., (*5)

use LasseRafn\Hexer\Hex;

// Lighten
$hex = new Hex('#333'); // You can leave out the hashtag if you wish.
echo $hex->lighten(15); // Output: #595959 (if you left out the hashtag, it would not be included in the output either)

// Darken
$hex = new Hex('ffffff');
echo $hex->darken(15); // Output: d9d9d9

// To RGB
$hex = new Hex('007F00');
$hex->lighten(50)->toRgb(); // Returns: ['r' => 128, 'g' => 255, 'b' => 128]

Methods

The constructor accepts one parameter (hex) which can optionally contain a hashtag (#). The length has to be between 3-6 characters (without the hashtag)., (*6)

lighten($percentage)

Will lighten the color by X percentage. Percentage must be between 0-100. An exception will be thrown otherwise., (*7)

darken($percentage)

Will darken the color by X percentage. Percentage must be between 0-100. An exception will be thrown otherwise., (*8)

toRgb()

Will return the hex as RGB (an array of r, g, b)., (*9)

Exceptions

If you input a HEX which is less than 3 characters of length, or greater than 6, an exception will be thrown. Similar with percentages, if you specify a percentage less than zero, or greater than 100, an exception will be thrown. If the percentage is zero, the hex itself will simply be returned., (*10)

Requirements

  • PHP 5.6, 7.0 or 7.1

The Versions

14/08 2017

dev-master

9999999-dev

A package to adjust brightness from a hex colorcode

  Sources   Download

MIT

The Requires

  • php ^5.6|^7.0|^7.1

 

The Development Requires

php color hex brightness

21/06 2017

dev-analysis-zdvNlg

dev-analysis-zdvNlg

A package to adjust brightness from a hex colorcode

  Sources   Download

MIT

The Requires

  • php ^5.6|^7.0|^7.1

 

The Development Requires

php color hex brightness

20/06 2017

v1.05

1.05.0.0

A package to adjust brightness from a hex colorcode

  Sources   Download

MIT

The Requires

  • php ^5.6|^7.0|^7.1

 

The Development Requires

php color hex brightness

16/06 2017

dev-analysis-8QpKep

dev-analysis-8QpKep

A package to adjust brightness from a hex colorcode

  Sources   Download

MIT

The Requires

  • php ^5.6|^7.0|^7.1

 

The Development Requires

php color hex brightness

16/06 2017

v1.01

1.01.0.0

A package to adjust brightness from a hex colorcode

  Sources   Download

MIT

The Requires

  • php ^5.6|^7.0|^7.1

 

The Development Requires

php color hex brightness

16/06 2017

v1.0

1.0.0.0

A package to adjust brightness from a hex colorcode

  Sources   Download

MIT

The Requires

  • php ^5.6|^7.0|^7.1

 

The Development Requires

php color hex brightness

16/06 2017

v0.8

0.8.0.0

A package to adjust brightness from a hex colorcode

  Sources   Download

MIT

The Requires

  • php ^5.6|^7.0|^7.1

 

The Development Requires

php color hex brightness