Rounding numbers

From: koswix14 Jun 2012 15:34
To: Dan (HERMAND) 14 of 18

\o/

 


I read a summary thing that one of my lecturers wrote about my assessments in a CAD class at college. He had written "you're drawings have continued to improve". He also continually goes on about what he's going to learn us, telling us that we've already drew something so it'll be easy. Amongst other cringe inducing phrases. A fucking /lecturer/. (fail)

From: Mikee14 Jun 2012 15:34
To: af (CAER) 15 of 18
My library can convert to/from Lab..

for example:

php code:
 
use MischiefCollective\ColorJizz\Formats\Hex;
 
// im not sure why you'd ever want to do this
echo Hex::fromString('CC0000')->toCIELab()->toHSV()->toRGB()->toHex()->toString(); // CC0000
 
// or..
use MischiefCollective\ColorJizz\Formats\CIELab;
echo CIELab::create(53, 80, 69)->toHex()->toString(); // FE0000
 


But at the moment, converting between RGB and CMYK and back first uses CMY internally.

for example..

php code:
 
 
class CMY {
  function toRGB() {
   return $this->toCMY()->toCMYK();
 }
 
}
 
class RGB {
  function toCMYK() {
    return $this->toCMY()->toRGB();
  }
}
 


I wonder if I can find a formula that does this all in a different way.. Hm.
From: Dan (HERMAND)15 Jun 2012 08:26
To: koswix 16 of 18
:(
From: Mikee15 Jun 2012 08:39
To: ALL17 of 18

Hmm.

 

Slowly started moving it over to namespaced PHP5.3 with some unit tests and whatnot.

 

https://github.com/mikeemoo/ColorJizz-PHP

 

Still a long way to do, and a whole load of comments to add!

 

It's not very extendable the way it is, though. Thinking of restructuring it so it's got more of a plugin-style system going on.

From: Matt15 Jun 2012 11:23
To: Mikee 18 of 18

Your extensibility looks fine, I wouldn't bother trying to make a plug-in style system, it'll just turn into a hideous mess of over-complicated checks involving method_exists and depending on how you do it, file_exists too, all of which will only slow it down.

 

The only thing I might do is make the arguments to your class methods all objects so you can type hint them and thus enforce them to be something more robust than PHP's crappy loose typing.

 

If you want to make it really easy to extend, and as you're targeting PHP 5.3, (you'll know this already of course) just make sure you're using the 'static' keyword when calling static functions and not self so they too can be overloaded / inherited. Also put things into suitably small chunks in properly scoped methods and well, that's about it.

EDITED: 15 Jun 2012 11:23 by MATT