apidoc
[ class tree: apidoc ] [ index: apidoc ] [ all elements ]

Class: Image_Color

Source Location: /Image_Color-1.0.1/Color.php

Class Overview


Color Handles and manages color mixing.


Author(s):

Version:

  • 0.2

Methods


Inherited Variables

Inherited Methods


Class Details

[line 54]
Color Handles and manages color mixing.

TODO: Eventually, I would like to expand upon this class to include other color types, and make it handle colors in a cleaner manner, however, as of right now, I would rather get it out rather than remain vaporware. At least this way, other people can take a look at it, and make suggestions. Besides, someone else might get more use out of it than I.

The class is really simple to use, and pretty much does its job fairly well. A sample of what can be done with this class is found here: http://www.newbienetwork.net/class.colour.php As you can well see, it is very good at what it does, and is rather quick. If someone has ideas or thoughts on this, please let me know. I would like expand it to handling image colors, as well as converting to CMYK, and even the dreaded Pantone(TM) colors! If someone knows of converting algo's or know of anything that might be of interest to me, let me know =). about it to.

Also, one more thing - Yes, I know, I will be try to get off the setColors() 2 color limitation, but since this script started out as a simple function that could _mix_ to colors together, it just kept going like that.

If you notice, the version is only 0.1. This is because I don't know of anyone really using it, and so it hasn't been tested completely. The more input I get back on it, the closer it goes to a 1.0 release.



[ Top ]


Method Detail

allocateColor   [line 472]

resource allocateColor( resource &$img, mixed $color)

Allocates a color in the given image.

Userdefined color specifications get translated into an array of rgb values.

  • Return: Image color handle
  • Access: public
  • See: color2RGB()

Parameters:

resource   &$img     Image handle
mixed   $color     (Userdefined) color specification

[ Top ]

changeLightness   [line 234]

void changeLightness( [int $degree = 10])

changeLightness Changes the lightness of the color.

The argument it takes determines the direction to go. If you give it a negative number, it will make the color darker, however, if you give it a positive number, it gets lighter.


Parameters:

int   $degree     degree The degree of the change you wish to take place.

[ Top ]

color2RGB   [line 483]

void color2RGB( mixed $color)


[ Top ]

getRange   [line 158]

array getRange( [string $degrees = 2])

getRange Given a degree, you can get the range of colors between one color and another color.
  • Return: Returns an array of all the colors, one element for each color.
  • Author: Jason Lotito <mailto:jason@lehighweb.com>
  • Access: public

Parameters:

string   $degrees     How much each 'step' between the colors we should take.

[ Top ]

getTextColor   [line 284]

void getTextColor( string $color, [mixed $light = 'FFFFFF'], [mixed $dark = '000000'], string $light(optional), string $dark(optional))

getTextColor Given a color, will return whether you should use a dark font or a light font.

You can change the dark and the light color, however by default, they are set to be 'white' (ffffff) and 'black' (000000), which are standard text colors. This is determined by the G(reen) value of RGB.


Parameters:

string   $color     The color to analyze
string   $light(optional)     The light color value to return if we should have light text
string   $dark(optional)     The dark color value to return if we should have dark text

[ Top ]

hex2rgb   [line 367]

array hex2rgb( string $hex)

hex2rgb Given a hex color, returns a 4 element array, with keys 0-2 containing the RGB values appropriately and with key 3 containing the original color.

Parameters:

string   $hex     The HEX string of the color.

[ Top ]

hsv2hex   [line 403]

string hsv2hex( integer $h, integer $s, integer $v)

hsv2hex Converts a HSV (Hue, Saturation, Brightness) value to Hexidecimal.

Originally written by @author. Integrated into Class by Jason Lotito.


Parameters:

integer   $h     Hue
integer   $s     Saturation
integer   $v     Brightness

[ Top ]

hsv2rgb   [line 385]

string hsv2rgb( integer $h, integer $s, integer $v)

hsv2rgb Converts a HSV (Hue, Saturation, Brightness) value to RGB.

Parameters:

integer   $h     Hue
integer   $s     Saturation
integer   $v     Brightness

[ Top ]

mixColors   [line 98]

void mixColors( [string(optional) $col1 = false], [string(optional) $col2 = false])

mixColors Given two colors, this will return a mix of the two together.

Parameters:

string(optional)   $col1     The first color you want to mix
string(optional)   $col2     The second color you want to mix

[ Top ]

namedColor2RGB   [line 509]

array namedColor2RGB( string $color)

Returns the RGB interger values of a named color, [0,0,0] if unknown.

The static variable $colornames is used to resolve the color names. Modify it if neccessary.

  • Return: [int red, int green, int blue], returns black [0, 0, 0] if the color is unknown.
  • Author: Sebastian Bergmann <mailto:sb@sebastian-bergmann.de>
  • Static: This method can be called statically
  • Access: public

Parameters:

string   $color     Case insensitive color name.

[ Top ]

percentageColor2RGB   [line 673]

array percentageColor2RGB( string $color)

Returns the RGB integer values of a color specified by a "percentage string" like "50%,20%,100%".
  • Return: [int red, int green, int blue]
  • Access: public

Parameters:

string   $color     

[ Top ]

rgb2hex   [line 351]

string rgb2hex( array $color)

rgb2hex Given an array of 3 elements containing RGB information, it will return a string of the HEX color.

Parameters:

array   $color     3 element array.

[ Top ]

setColors   [line 143]

void setColors( string $col1, string $col2)

setColors This class primarily works with two colors, and using this function, you can easily set both colors.

Parameters:

string   $col1     The first color in hex format
string   $col2     The second color in hex format

[ Top ]

setWebSafe   [line 128]

void setWebSafe( [bool=true $bool = true])

setWebSafe Sets whether we should output websafe colors or not.

Parameters:

bool=true   $bool     If set to true (def.), websafe is on, otherwise not.

[ Top ]


Documentation generated on Tue, 25 May 2004 03:30:03 -0400 by phpDocumentor 1.2.3. PEAR Logo Copyright © PHP Group 2004.