Welcome Guest, Not a member yet? Register   Sign In
Where to put this 3rd party PHP package?
#9

[eluser]Mikeemoo[/eluser]
Hi,

Just convert it to a Hex, then use toString() to get it as a string representation.

For example:

Code:
echo new RGB(255, 0, 0)->toHex()->toString(); // prints "FF0000"
echo new Hex(0x00FF00)->toString(); // prints "00FF00"
echo new Hex::fromString("#0000FF")->toString(); // prints "0000FF"
echo new Hex(0xFF0000)->toRGB()->toString(); // prints 255,0,0

// draw 10 colors ranging from green to red..
foreach (new RGB(0, 255, 0)->range(new Hex(0xFF0000), 10) as $color){
  echo $color->toHex()->toString();
}

You can string as many conversions together as you like and it should still work (although it'd be mostly pointless..)

For example:

Code:
echo new Hex(0xFF0000)->toCIELab()->toCIELCh()->toRGB()->toCMYK()->toHex()->toString(); // hopefully comes out as FF0000!

Every color format has a "to" method that will convert to any other color format.


Messages In This Thread
Where to put this 3rd party PHP package? - by El Forum - 10-19-2010, 02:20 AM
Where to put this 3rd party PHP package? - by El Forum - 10-19-2010, 03:39 AM
Where to put this 3rd party PHP package? - by El Forum - 10-19-2010, 03:42 AM
Where to put this 3rd party PHP package? - by El Forum - 10-19-2010, 04:01 AM
Where to put this 3rd party PHP package? - by El Forum - 10-19-2010, 10:36 AM
Where to put this 3rd party PHP package? - by El Forum - 10-19-2010, 10:29 PM
Where to put this 3rd party PHP package? - by El Forum - 10-20-2010, 03:07 AM
Where to put this 3rd party PHP package? - by El Forum - 10-20-2010, 11:08 AM
Where to put this 3rd party PHP package? - by El Forum - 10-20-2010, 12:35 PM
Where to put this 3rd party PHP package? - by El Forum - 10-20-2010, 12:54 PM



Theme © iAndrew 2016 - Forum software by © MyBB