Well, let's get down to business
I've posted this in another php forum but had no replies and as I think this is a larger community and a good one... here it is
I'm making a Color class with conversions between different colorspaces, colors, etc. so it can be helpful later to use with image libraries, like GD or ImageMagick...
So I've come to a point where I don't know what to do. A lot of ways of implementing this class come to my head and I don't know which one would be the best to keep working on (I mean, it isn't finished and I don't want to write both, I'd like to choose one). So that's basically what I want you to help me with... to choose one of these two. The one you think would be better in every aspect especially when processing images.
Also if you find any errors, or have any ideas, anything... please let me know i will really appreciate it
Attached are the two implementations.
Below I post some basic examples of how to use each one but I think it's easy enough.
color.class.php:
Code: Select all
<?php
require_once("color.class.php");
print Color::rgb2hex(array(255,0,255),0,1);
print "<br/>";
$col = new Color;
$col->set_from_hex("#FF0000");
$col2 = new Color;
$col2->set_from_cmy(0, 1, 1);
print $col2->get_hex(1, 1);
print "<br/>";
?>Code: Select all
<?php
require_once("color.class2.php");
$rgb1 = new rgbColor(255,0,0,255);
$rgb2 = new rgbColor(255,0,0,255);
$cmy = new cmyColor(0,1,1,1);
$cmyk = new cmykColor(0,1,1,0,1);
print $rgb1->equals($rgb2);
print "<br/>";
print $cmyk;
print "<br/>";
print ColorConverter::toCmyk($rgb1);
print "<br/>";
print $rgb1->getAlpha();
?>P.S: In case you aren't familiar with colorspaces... RGB components are in the range 0..255, CMY and CMYK in the range 0..1, and notice the second implementation has also alpha channel while the first one doesn't (just cause when I wrote it I didn't think about it...