Giter Site home page Giter Site logo

backlight's Introduction

Backlight

Backlight is a pointless script inspired by the Ubuntu Unity Launcher. It will take an image/icon, and find it's mean background color as well as it's glow color. It will return an object with values in both RGB and HEX format for use.

Fetch

The recommended way to install Backlight is through composer.

Just create a composer.json file for your project:

{
    "minimum-stability" : "dev",
    "require": {
        "tyler-king/backlight": "dev-master"
    }
}

And run these two commands to install it:

$ curl -s http://getcomposer.org/installer | php
$ php composer.phar install

Now you can add the autoloader, and you will have access to the library:

<?php
require 'vendor/autoload.php';

Usage

The usage is pretty stright forward, very chainable (see the source). This is a basic example below.

<?php

use TylerKing\Backlight\Backlight;

$backlight = new Backlight('chrome-icon.png');
print_r($backlight->getBackground()); // Returns the RGB and HEX of the background to use.
print_r($backlight->getMean()); // Returns the RGB and HEX of the outter glow to use.

By running print_r or var_dump you will receieve an output containing the mean background-color and the glow color for the icon or image.

stdClass Object
(
    [background] => stdClass Object
        (
            [rgb] => Array
                (
                    [0] => 192
                    [1] => 123
                    [2] => 18
                )

            [hex] => #c07b12
        )

    [glow] => stdClass Object
        (
            [rgb] => Array
                (
                    [0] => 229
                    [1] => 146
                    [2] => 22
                )

            [hex] => #e59216
        )

)

You can also pointlessly convert the image to pure HTML/CSS.

<?php

use TylerKing\Backlight\Backlight;

$backlight = new Backlight('chrome-icon.png');
file_put_contents('image.html', $backlight->toHTML());

By opening image.html in your browser you will now see the image in HTML/CSS format.

Notes

  • This library uses Imagick library.
  • Required PHP 5.4
  • Supported image types currently is with PNG and JPG.

backlight's People

Stargazers

 avatar  avatar  avatar

Forkers

szymek

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.