[ Index ]
 

Code source de vtiger CRM 5.0.2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/Image/ -> Color.php (sommaire)

Color.php is the implementation of Image_Color. PHP versions 4 and 5

Author: Jason Lotito <jason@lehighweb.com>
Author: Andrew Morton <drewish@katherinehouse.com>
Copyright: 2003-2005 The PHP Group
License: http://www.php.net/license/3_0.txt PHP License 3.0
Version: CVS: $Id: Color.php,v 1.15 2005/09/12 19:12:02 drewish Exp $
Poids: 719 lignes (27 kb)
Inclus ou requis: 1 fois
Référencé: 0 fois
Nécessite: 0 fichiers

Définit 1 class

Image_Color:: (18 méthodes):
  mixColors()
  setWebSafe()
  setColors()
  getRange()
  changeLightness()
  getTextColor()
  _setColors()
  _splitColor()
  _returnColor()
  rgb2hex()
  hex2rgb()
  hsv2rgb()
  hsv2hex()
  allocateColor()
  color2RGB()
  namedColor2RGB()
  percentageColor2RGB()
  _makeWebSafe()


Classe: Image_Color  - X-Ref

Image_Color handles color conversion and mixing.

The class is quick, simple to use, and does its job fairly well but it's got
some code smells:
- Call setColors() for some functions but not others.
- Different functions expect different color formats. setColors() only
accepts hex while allocateColor() will accept named or hex (provided the
hex ones start with the # character).
- Some conversions go in only one direction, ie HSV->RGB but no RGB->HSV.
I'm going to try to straighten out some of this but I'll be hard to do so
without breaking backwards compatibility.

mixColors($col1 = false, $col2 = false)   X-Ref
Mix two colors together by finding their average. If the colors are not
passed as parameters, the class's colors will be mixed instead.

author: Jason Lotito <jason@lehighweb.com>
param: string  $col1 The first color you want to mix
param: string  $col2 The second color you want to mix
return: string  The mixed color.

setWebSafe($bool = true)   X-Ref
Determines whether colors the returned by this class will be rounded to
the nearest web safe value.

author: Jason Lotito <jason@lehighweb.com>
param: boolean $bool Indicates if colors should be limited to the
return: void

setColors($col1, $col2)   X-Ref
Set the two colors this class uses for mixing and ranges.

author: Jason Lotito <jason@lehighweb.com>
param: string  $col1 The first color in hex format
param: string  $col2 The second color in hex format
return: void

getRange($degrees = 2)   X-Ref
Get the range of colors between the class's two colors, given a degree.

author: Jason Lotito <jason@lehighweb.com>
param: integer $degrees How large a 'step' we should take between the
return: array   Returns an array of hex strings, one element for each

changeLightness($degree = 10)   X-Ref
Change the lightness of the class's two colors.

author: Jason Lotito <jason@lehighweb.com>
param: integer     $degree The degree of the change. Positive values
return: void

getTextColor($color, $light = ')   X-Ref
Determine if a light or dark text color would be more readable on a
background of a given color. This is determined by the G(reen) value of
RGB. You can change the dark and the light colors from their default
black and white.

author: Jason Lotito <jason@lehighweb.com>
param: string  $color The hex color to analyze
param: string  $light The light color value to return if we should
param: string  $dark The dark color value to return if we should have
return: string  The light or dark value which would make the text most

_setColors($col1, $col2)   X-Ref
Internal method to set the colors.

author: Jason Lotito <jason@lehighweb.com>
param: string  $col1 First color, either a name or hex value
param: string  $col2 Second color, either a name or hex value
return: void

_splitColor($color)   X-Ref
Given a color, properly split it up into a 3 element RGB array.

author: Jason Lotito <jason@lehighweb.com>
param: string  $color The color.
return: array   A three element RGB array.

_returnColor( $color )   X-Ref
This is deprecated. Use rgb2hex() instead.


rgb2hex($color)   X-Ref
Convert an RGB array to a hex string.

author: Jason Lotito <jason@lehighweb.com>
param: array   $color 3 element RGB array.
return: string  Hex color string.

hex2rgb($hex)   X-Ref
Convert a hex color string into an RGB array. An extra fourth element
will be returned with the original hex value.

author: Jason Lotito <jason@lehighweb.com>
param: string  $hex Hex color string.
return: array   RGB color array with an extra 'hex' element containing

hsv2rgb($h, $s, $v)   X-Ref
Convert an HSV (Hue, Saturation, Brightness) value to RGB.

author: Jason Lotito <jason@lehighweb.com>
param: integer $h Hue
param: integer $s Saturation
param: integer $v Brightness
return: array   RGB array.

hsv2hex($h, $s, $v)   X-Ref
Convert HSV (Hue, Saturation, Brightness) to a hex color string.

Originally written by Jurgen Schwietering. Integrated into the class by
Jason Lotito.

author: Jurgen Schwietering <jurgen@schwietering.com>
param: integer $h Hue
param: integer $s Saturation
param: integer $v Brightness
return: string  The hex string.

allocateColor(&$img, $color)   X-Ref
Allocates a color in the given image.

User defined color specifications get translated into an array of RGB
values.

param: resource        $img Image handle
param: string|array    $color Name or hex string or an RGB array.
return: resource        Image color handle.

color2RGB($color)   X-Ref
Convert a named or hex color string to an RGB array. If the color begins
with the # character it will be treated as a hex value. Everything else
will be treated as a named color. If the named color is not known, black
will be returned.

author: Laurent Laville <pear@laurent-laville.org>
param: string  $color
return: array   RGB color

namedColor2RGB($color)   X-Ref
Convert a named color to an RGB array. If the color is unknown black
is returned.

author: Sebastian Bergmann <sb@sebastian-bergmann.de>
param: string  $color Case insensitive color name.
return: array   RGB color array. If the color was unknown, the result

percentageColor2RGB($color)   X-Ref
Convert an RGB percentage string into an RGB array.

param: string  $color Percentage color string like "50%,20%,100%".
return: array   RGB color array.

_makeWebSafe(&$color)   X-Ref
Function for array_walk() to round colors to the closest web safe value.

author: Jason Lotito <jason@lehighweb.com>
author: Andrew Morton <drewish@katherinehouse.com>
param: integer $color One channel of an RGB color.
return: integer The websafe equivalent of the color channel.



Généré le : Sun Feb 25 10:22:19 2007 par Balluche grâce à PHPXref 0.7