Overview

Packages

  • AlfredBundler
  • None

Classes

  • AlfredBundler
  • AlfredBundlerIcon
  • AlfredBundlerInternalClass
  • AlfredBundlerLogger
  • Overview
  • Package
  • Class
  • Tree

Class AlfredBundlerIcon

A class used to get / manipulate icons...

Package: AlfredBundler
Copyright: The Alfred Bundler Team 2014
License: MIT
Since: Class available since Taurus 1
TODO: document further
Located at AlfredBundlerIcon.php
Methods summary
public
# __construct( object $bundler )

Sets the variables to deal with icons

Sets the variables to deal with icons

Parameters

$bundler
object
$bundler the bundler object that instantiates this

Since

Taurus 1
public
# validateBackground( )

Sets the theme background to dark if it isn't set

Sets the theme background to dark if it isn't set

Since

Taurus 1

See

setBackground()
public mixed
# icon( array $args )

Returns a path to an icon

Returns a path to an icon

Parameters

$args
array
$args Associative array that evaluates to [ 'font' => font, 'name' => icon-name, 'color' => hex-color, 'alter' => hex-color|bool ]. The first two are mandatory; color defaults to '000000', and alter defaults to FALSE.

Returns

mixed
FALSE on user error, and file path on success

Since

Taurus 1

See

parseIconArguments()
getSystemIcon()
AlfredBundlerIcon::getIcon()
AlfredBundlerIcon::downloadIcon()
AlfredBundlerIcon::tryServers()
AlfredBundlerIcon::validateImage()
AlfredBundlerIcon::color()
AlfredBundlerIcon::prepareIcon()

Link

[http://icons.deanishe.net] [Icon server documentation]
public string
# getIcon( array $args )

Queries server to download non-local icon

Queries server to download non-local icon

Parameters

$args
array
$args Same args as icon()

Returns

string
Path to icon or fallback

Since

Taurus 1

See

AlfredBundlerIcon::icon()
public boolean
# tryServers( array $args, string $icon )

Cycles through a list of servers to download an icon

Cycles through a list of servers to download an icon

The method tries to get the icon from the first server, if the server is unreachable, then it will go down the list until it succeeds. If none are available, then it reports its failure.

Parameters

$args
array
$args associative array containing suburl arguments: font, name, color
$icon
string
$icon filepath to icon destination

Returns

boolean
TRUE on success, FALSE on failure

Since

Taurus 1

See

AlfredBundlerIcon::icon()
AlfredBundlerIcon::getIcon()
AlfredBundlerIcon::downloadIcon()
public integer
# downloadIcon( string $url, string $icon )

Downloads an icon from a server

Downloads an icon from a server

Parameters

$url
string
$url url to file
$icon
string
$icon path to file destination

Returns

integer
cURL exit status

Since

Taurus 1

See

AlfredBundlerIcon::icon()
AlfredBundlerIcon::getIcon()
AlfredBundlerIcon::tryServers()
public boolean
# validateImage( string $image )

Checks a file to see if it is a png.

Checks a file to see if it is a png.

Parameters

$image
string
$image file path to alleged image

Returns

boolean
TRUE is a png, FALSE if not

Since

Taurus 1
public string
# color( string $color )

Normalizes and validates a color and adds it to the color array

Normalizes and validates a color and adds it to the color array

Parameters

$color
string
$color a hex color

Returns

string
a hex normalized and validated hex color

Since

Taurus 1

See

AlfredBundlerIcon::prepareIcon()
AlfredBundlerIcon::checkHex()
AlfredBundlerIcon::validateHex()
AlfredBundlerIcon::normalizeHex()
AlfredBundlerIcon::rgb()
AlfredBundlerIcon::hsv()
AlfredBundlerIcon::luminance()
brightness()
AlfredBundlerIcon::altered()
AlfredBundlerIcon::hexToRgb()
AlfredBundlerIcon::rgbToHex()
AlfredBundlerIcon::rgbToHsv()
AlfredBundlerIcon::hsvToRgb()
AlfredBundlerIcon::alter()
AlfredBundlerIcon::getLuminance()
AlfredBundlerIcon::getBrightness()
public array
# prepareIcon( array $args )

Prepares the icon arguments for a proper query

Prepares the icon arguments for a proper query

The color is first normalized. Then, if the alter variable has not been set, then it just send the arguments back. Otherwise a check is run to see if the theme background color is the same as the proposed icon color. If not, then it sends back the arguments. If so, then, if the alter variable is another hex color, it returns that. If, instead, it is TRUE, then alters the color accordingly so that the icon will best appear on the background.

Parameters

$args
array
$args an associative array of args passed to icon()

Returns

array
possible altered array of args to load an icon

Since

Taurus 1

See

AlfredBundlerIcon::icon()
AlfredBundlerIcon::color()
AlfredBundlerIcon::checkHex()
AlfredBundlerIcon::validateHex()
AlfredBundlerIcon::normalizeHex()
AlfredBundlerIcon::rgb()
AlfredBundlerIcon::hsv()
AlfredBundlerIcon::luminance()
brightness()
AlfredBundlerIcon::altered()
AlfredBundlerIcon::hexToRgb()
AlfredBundlerIcon::rgbToHex()
AlfredBundlerIcon::rgbToHsv()
AlfredBundlerIcon::hsvToRgb()
AlfredBundlerIcon::alter()
AlfredBundlerIcon::getLuminance()
AlfredBundlerIcon::getBrightness()
public array
# rgb( string $color )

Returns the RGB of a color, and it sets it if necessary

Returns the RGB of a color, and it sets it if necessary

Parameters

$color
string
$color hex color

Returns

array
associative array of RGB values

Since

Taurus 1

See

AlfredBundlerIcon::color()
AlfredBundlerIcon::prepareIcon()
AlfredBundlerIcon::checkHex()
AlfredBundlerIcon::validateHex()
AlfredBundlerIcon::normalizeHex()
AlfredBundlerIcon::hsv()
AlfredBundlerIcon::luminance()
brightness()
AlfredBundlerIcon::altered()
AlfredBundlerIcon::hexToRgb()
AlfredBundlerIcon::rgbToHex()
AlfredBundlerIcon::rgbToHsv()
AlfredBundlerIcon::hsvToRgb()
AlfredBundlerIcon::alter()
AlfredBundlerIcon::getLuminance()
AlfredBundlerIcon::getBrightness()
public array
# hsv( string $color )

Returns the HSV of a color, and it sets it if necessary

Returns the HSV of a color, and it sets it if necessary

Parameters

$color
string
$color hex color

Returns

array
associative array of HSV values

Since

Taurus 1

See

AlfredBundlerIcon::color()
AlfredBundlerIcon::prepareIcon()
AlfredBundlerIcon::checkHex()
AlfredBundlerIcon::validateHex()
AlfredBundlerIcon::normalizeHex()
AlfredBundlerIcon::rgb()
AlfredBundlerIcon::luminance()
brightness()
AlfredBundlerIcon::altered()
AlfredBundlerIcon::hexToRgb()
AlfredBundlerIcon::rgbToHex()
AlfredBundlerIcon::rgbToHsv()
AlfredBundlerIcon::hsvToRgb()
AlfredBundlerIcon::alter()
AlfredBundlerIcon::getLuminance()
AlfredBundlerIcon::getBrightness()

Link

[https://en.wikipedia.org/wiki/HSL_and_HSV] [color forumulas]
public string
# altered( string $color )

Retrieves the altered color of the original

Retrieves the altered color of the original

Parameters

$color
string
$color a hex color

Returns

string
a hex color (lighter or darker than the original)

Since

Taurus 1

See

AlfredBundlerIcon::color()
AlfredBundlerIcon::prepareIcon()
AlfredBundlerIcon::checkHex()
AlfredBundlerIcon::validateHex()
AlfredBundlerIcon::normalizeHex()
AlfredBundlerIcon::rgb()
AlfredBundlerIcon::hsv()
AlfredBundlerIcon::luminance()
brightness()
AlfredBundlerIcon::hexToRgb()
AlfredBundlerIcon::rgbToHex()
AlfredBundlerIcon::rgbToHsv()
AlfredBundlerIcon::hsvToRgb()
AlfredBundlerIcon::alter()
AlfredBundlerIcon::getLuminance()
AlfredBundlerIcon::getBrightness()
public float
# luminance( string $color )

Retrieves the luminance of a hex color

Retrieves the luminance of a hex color

Parameters

$color
string
$color a hex color

Returns

float
the luminance between 0 and 1

Since

Taurus 1

See

AlfredBundlerIcon::color()
AlfredBundlerIcon::prepareIcon()
AlfredBundlerIcon::checkHex()
AlfredBundlerIcon::validateHex()
AlfredBundlerIcon::normalizeHex()
AlfredBundlerIcon::rgb()
AlfredBundlerIcon::hsv()
brightness()
AlfredBundlerIcon::altered()
AlfredBundlerIcon::hexToRgb()
AlfredBundlerIcon::rgbToHex()
AlfredBundlerIcon::rgbToHsv()
AlfredBundlerIcon::hsvToRgb()
AlfredBundlerIcon::alter()
AlfredBundlerIcon::getLuminance()
AlfredBundlerIcon::getBrightness()
public array
# hexToRgb( string $hex )

Converts a Hex color to an RGB Color

Converts a Hex color to an RGB Color

Parameters

$hex
string
$color A hex color

Returns

array
An array of RGB values

Since

Taurus 1

See

AlfredBundlerIcon::color()
prepareicon()
checkhex()
validatehex()
normalizehex()
AlfredBundlerIcon::rgb()
AlfredBundlerIcon::hsv()
AlfredBundlerIcon::luminance()
brightness()
AlfredBundlerIcon::altered()
rgbtohex()
rgbtohsv()
hsvtorgb()
AlfredBundlerIcon::alter()
getluminance()
AlfredBundlerIcon::getBrightness()
public string
# rgbToHex( array $rgb )

Converts an RGB color to a Hex color

Converts an RGB color to a Hex color

Parameters

$rgb
array
$rgb an associative array of RGB values

Returns

string
a hex color

Since

Taurus 1

See

AlfredBundlerIcon::color()
AlfredBundlerIcon::prepareIcon()
AlfredBundlerIcon::checkHex()
AlfredBundlerIcon::validateHex()
AlfredBundlerIcon::normalizeHex()
AlfredBundlerIcon::rgb()
AlfredBundlerIcon::hsv()
AlfredBundlerIcon::luminance()
brightness()
AlfredBundlerIcon::altered()
AlfredBundlerIcon::hexToRgb()
AlfredBundlerIcon::rgbToHsv()
AlfredBundlerIcon::hsvToRgb()
AlfredBundlerIcon::alter()
AlfredBundlerIcon::getLuminance()
AlfredBundlerIcon::getBrightness()
public array
# rgbToHsv( array $rgb )

Converts RGB color to HSV color

Converts RGB color to HSV color

Parameters

$rgb
array
$rgb associative array of rgb values

Returns

array
an associate array of hsv values

Since

Taurus 1

See

AlfredBundlerIcon::color()
AlfredBundlerIcon::prepareIcon()
AlfredBundlerIcon::checkHex()
AlfredBundlerIcon::validateHex()
AlfredBundlerIcon::normalizeHex()
AlfredBundlerIcon::rgb()
AlfredBundlerIcon::hsv()
AlfredBundlerIcon::luminance()
brightness()
AlfredBundlerIcon::altered()
AlfredBundlerIcon::hexToRgb()
AlfredBundlerIcon::rgbToHex()
AlfredBundlerIcon::hsvToRgb()
AlfredBundlerIcon::alter()
AlfredBundlerIcon::getLuminance()
AlfredBundlerIcon::getBrightness()

Link

[https://en.wikipedia.org/wiki/HSL_and_HSV] [color forumulas]
public array
# hsvToRgb( array $hsv )

Convert HSV color to RGB

Convert HSV color to RGB

Parameters

$hsv
array
$hsv associative array of hsv values ( 0 <= h < 360, 0 <= s <= 1, 0 <= v <= 1)

Returns

array
An array of RGB values

Since

Taurus 1

See

AlfredBundlerIcon::color()
AlfredBundlerIcon::prepareIcon()
AlfredBundlerIcon::checkHex()
AlfredBundlerIcon::validateHex()
AlfredBundlerIcon::normalizeHex()
AlfredBundlerIcon::rgb()
AlfredBundlerIcon::hsv()
AlfredBundlerIcon::luminance()
brightness()
AlfredBundlerIcon::altered()
AlfredBundlerIcon::hexToRgb()
AlfredBundlerIcon::rgbToHex()
AlfredBundlerIcon::rgbToHsv()
AlfredBundlerIcon::alter()
AlfredBundlerIcon::getLuminance()
AlfredBundlerIcon::getBrightness()

Link

[https://en.wikipedia.org/wiki/HSL_and_HSV] [color forumulas]
public float
# getLuminance( mixed $color )

Gets the luminance of a color between 0 and 1

Gets the luminance of a color between 0 and 1

Parameters

$color
mixed
$color a hex color (string) or an associative array of RGB values

Returns

float
Luminance on a scale of 0 to 1

Since

Taurus 1

See

AlfredBundlerIcon::color()
AlfredBundlerIcon::prepareIcon()
AlfredBundlerIcon::checkHex()
AlfredBundlerIcon::validateHex()
AlfredBundlerIcon::normalizeHex()
AlfredBundlerIcon::rgb()
AlfredBundlerIcon::hsv()
AlfredBundlerIcon::luminance()
brightness()
AlfredBundlerIcon::altered()
AlfredBundlerIcon::hexToRgb()
AlfredBundlerIcon::rgbToHex()
AlfredBundlerIcon::rgbToHsv()
AlfredBundlerIcon::hsvToRgb()
AlfredBundlerIcon::alter()
AlfredBundlerIcon::getBrightness()

Link

https://en.wikipedia.org/wiki/Luminance_(relative)
https://en.wikipedia.org/wiki/Luma_(video)
https://en.wikipedia.org/wiki/CCIR_601
public string
# getBrightness( string $color )

Determines whether a color is 'light' or 'dark'

Determines whether a color is 'light' or 'dark'

Parameters

$color
string
$color a hex color

Returns

string
either 'light' or 'dark'

Since

Taurus 1

See

AlfredBundlerIcon::color()
AlfredBundlerIcon::prepareIcon()
AlfredBundlerIcon::checkHex()
AlfredBundlerIcon::validateHex()
AlfredBundlerIcon::normalizeHex()
AlfredBundlerIcon::rgb()
AlfredBundlerIcon::hsv()
AlfredBundlerIcon::luminance()
brightness()
AlfredBundlerIcon::altered()
AlfredBundlerIcon::hexToRgb()
AlfredBundlerIcon::rgbToHex()
AlfredBundlerIcon::rgbToHsv()
AlfredBundlerIcon::hsvToRgb()
AlfredBundlerIcon::alter()
AlfredBundlerIcon::getLuminance()
public string
# alter( string $color )

Either lightens or darkens an image

Either lightens or darkens an image

The function starts with a hex color and converts it into an RGB color space and then to an HSV color space. The V(alue) in HSV is set between 0 (black) and 1 (white), which is a measure of 'brightness' where 0.5 is neutral. Thus, we retain the hue and saturation and keep the relative brightness of the color by pushing it on the other side of neutral but at the same distance from neutral. E.g.: 0.7 becomes 0.3; 0.12 becomes 0.88; 0.0 becomes 1.0; and 0.5 becomes 0.5.

Parameters

$color
string
$color a hex color

Returns

string
a hex color

Since

Taurus 1

See

AlfredBundlerIcon::color()
AlfredBundlerIcon::prepareIcon()
AlfredBundlerIcon::checkHex()
AlfredBundlerIcon::validateHex()
AlfredBundlerIcon::normalizeHex()
AlfredBundlerIcon::rgb()
AlfredBundlerIcon::hsv()
AlfredBundlerIcon::luminance()
brightness()
AlfredBundlerIcon::altered()
AlfredBundlerIcon::hexToRgb()
AlfredBundlerIcon::rgbToHex()
AlfredBundlerIcon::rgbToHsv()
AlfredBundlerIcon::hsvToRgb()
AlfredBundlerIcon::getLuminance()
AlfredBundlerIcon::getBrightness()
public mixed
# checkHex( string $hex )

Checks to see if a color is a valid hex and normalizes the hex color

Checks to see if a color is a valid hex and normalizes the hex color

Parameters

$hex
string
$color A hex color

Returns

mixed
FALSE on non-hex or hex color (normalized) to six characters and lowercased

Since

Taurus 1

See

AlfredBundlerIcon::color()
AlfredBundlerIcon::prepareIcon()
AlfredBundlerIcon::validateHex()
AlfredBundlerIcon::normalizeHex()
AlfredBundlerIcon::rgb()
AlfredBundlerIcon::hsv()
AlfredBundlerIcon::luminance()
brightness()
AlfredBundlerIcon::altered()
AlfredBundlerIcon::hexToRgb()
AlfredBundlerIcon::rgbToHex()
AlfredBundlerIcon::rgbToHsv()
AlfredBundlerIcon::hsvToRgb()
AlfredBundlerIcon::alter()
AlfredBundlerIcon::getLuminance()
AlfredBundlerIcon::getBrightness()
public string
# normalizeHex( string $hex )

Normalizes all hex colors to six, lowercase characters

Normalizes all hex colors to six, lowercase characters

Parameters

$hex
string
$hex a hex color

Returns

string
a normalized hex color

Since

Taurus 1

See

AlfredBundlerIcon::color()
AlfredBundlerIcon::prepareIcon()
AlfredBundlerIcon::checkHex()
AlfredBundlerIcon::validateHex()
AlfredBundlerIcon::rgb()
AlfredBundlerIcon::hsv()
AlfredBundlerIcon::luminance()
brightness()
AlfredBundlerIcon::altered()
AlfredBundlerIcon::hexToRgb()
AlfredBundlerIcon::rgbToHex()
AlfredBundlerIcon::rgbToHsv()
AlfredBundlerIcon::hsvToRgb()
AlfredBundlerIcon::alter()
AlfredBundlerIcon::getLuminance()
AlfredBundlerIcon::getBrightness()
public mixed
# validateHex( string $hex )

Validates a hex color

Validates a hex color

Parameters

$hex
string
$hex a hex color

Returns

mixed
FALSE on failure, the hex value on success

Since

Taurus 1

See

AlfredBundlerIcon::color()
AlfredBundlerIcon::prepareIcon()
AlfredBundlerIcon::checkHex()
AlfredBundlerIcon::normalizeHex()
AlfredBundlerIcon::rgb()
AlfredBundlerIcon::hsv()
AlfredBundlerIcon::luminance()
brightness()
AlfredBundlerIcon::altered()
AlfredBundlerIcon::hexToRgb()
AlfredBundlerIcon::rgbToHex()
AlfredBundlerIcon::rgbToHsv()
AlfredBundlerIcon::hsvToRgb()
AlfredBundlerIcon::alter()
AlfredBundlerIcon::getLuminance()
AlfredBundlerIcon::getBrightness()
Properties summary
public mixed $background
#
public mixed $data
#
public mixed $cache
#
Alfred Bundler API documentation generated by ApiGen 2.8.0