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

Class: Image_Color2_Model

Source Location: /Image_Color2-0.1.5/Image/Color2/Model.php

Class Overview


An interface for color model classes to allow conversion of colors to and from RGB. This class should be imutable, meaning that once it's constructed the value is not changed.


Author(s):

Copyright:

  • 2005 Andrew Morton

Methods


Inherited Variables

Inherited Methods


Class Details

[line 36]
An interface for color model classes to allow conversion of colors to and from RGB. This class should be imutable, meaning that once it's constructed the value is not changed.


[ Top ]


Method Detail

fromArray   [line 88]

Image_ColorModel fromArray( array $array)

Create an Image_Color2_Model from an array of values.

Color models like CMYK and HSL have some components that are typically expressed as either percentages or floating point values from 0.0 to 1.0. This function tries to be very accomidating, if the value is followed by a percent sign (%) it will be divided by 100 and then treated as a zero to one floating point value.

  • See: Image_Color2_Model::getArray()
  • Throws: PEAR_Exception On an error an exception maybe thrown or null returned, it's up to the implementation.
  • Access: public

Parameters:

array   $array   —  The values and order are specific to each color model. There may be an optional type element at the end of the array. i.e: array(0, 255, 0, 'type' => 'rgb')

[ Top ]

fromRgb   [line 59]

Image_ColorModel fromRgb( array $rgb)

Create an Image_Color2_Model from an RGB array.

  • See: Image_Color2_Model::getRgb()
  • Throws: PEAR_Exception On an error an exception maybe thrown or null returned, it's up to the implementation.
  • Access: public

Parameters:

array   $rgb   —  A PEAR style RGB array containing three integers from 0 to 255 for the Red, Green, and Blue color components followed by a 'type' => 'rgb' element.

[ Top ]

fromString   [line 130]

Image_ColorModel fromString( string $str)

Create an Image_ColorModel from a color model specific string.

Color models like CMYK and HSL have some components that are typically expressed as either percentages or floating point values from 0.0 to 1.0. This function tries to be very accomidating, if the value is followed by a percent sign (%) it will be divided by 100 and then treated as a zero to one floating point value.

The color's channels can be separated using a comma, a space or both.

Examples of string formats used by several implementations of this interface:

 Hex: '#abcdef'
 Named: 'black'
 CMYK: '100% 0% 75% 20%' or '1, 0, .75, .2'
 HSL: '135, 100%, 40%' or '135 1.0 0.4'

  • See: Image_Color2_Model::getString()
  • Throws: PEAR_Exception On an error an exception maybe thrown or null returned, it's up to the implementation.
  • Access: public

Parameters:

string   $str   —  a string in a color model dependant format.

[ Top ]

getArray   [line 156]

array getArray( )

Get an array of values to represent a color in this color model. This should be parseable by fromArray() and should include a type element.


[ Top ]

getRgb   [line 142]

array getRgb( )

Get an RGB array of the color.

The 'type' => 'rgb' element must be included as the last element.

  • Return: A PEAR style RGB array containing three integers from 0 to 255 for the Red, Green, and Blue color components followed by a 'type' => 'rgb' element.
  • See: Image_Color2_Model::fromRgb()
  • Access: public

[ Top ]

getString   [line 178]

string getString( )

Get a string to represent a color in this color model. The string should be parsable by fromString().

 HSL: '135, 100%, 40%'
 CMYK: '100%, 0%, 75%, 20%'
 Hex: '#00cc33'


[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:39:06 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.