I needed to do some colorspace computations in PHP and noted that there isn’t so much code/libraries out there, compared to other programming languages. Surely, you could just use high-level APIs such as Imagick or GD, both of which have PHP interfaces, but that would have created too much overhead for me.
Rather, I thought, I should get me old computer graphics books out and implement it myself. Colorspaces are usually represented as “color cubes” such as the RGB cube, i.e. the three component colors are represented by three perpendicular axes forming a 3d vector space.
To my amazement, there isn’t much in terms of libraries for 3d math out there as well, so I had to roll my own 3d math PHP class. Not a big deal, if you understand the underlying math. There are plenty of books and websites walking you through it, and I read a lot…
View original post 142 more words