[Haskell-cafe] Mini-announce: AC-Color 1.1.3

Andrew Coppin andrewcoppin at btinternet.com
Mon Mar 8 16:09:10 EST 2010


I just uploaded a new version of the ever-unpopular AC-Colour package. 
(Yes, there's a country where it's spelled that way.)

What it already did: Provides a simple strict unboxed RGB colour type, 
with arithmetic. The three channels can be either Double or Word8. (And 
there's some low-level hackery to convert between the two. For some 
reason just using "floor" is awesomely slow, but talking to GHC.Prim 
directly is much, much faster... which unfortunately makes this package 
far less portable than it should be!)

What it does now: Colour maps. Give it some control points, and it'll 
(linearly) interpolate between them to give you a function Double -> 
Colour. (I haven't seen anything else on Hackage that will do this 
out-of-the-box. I've seen linear blends between two colours, but not 
fully automatic piece-wise linear maps like this.)

Now obviously none of this is terribly earth-shattering. But I find 
myself needing this often enough that it's annoying to have to spend 10 
minutes coding and debugging it every single time I want it. Maybe 
somebody else will find a use for it too. I paid special attention to 
trying to make the colour maps as general as possible. (E.g., the 
parameter range isn't limited to [0..1], it's arbitrary. Going off the 
end of the range produces sensible results. You can make the map loop. 
And so on.)

Maybe if I'm feeling ambitious I'll try 2D colour maps. (Of course, the 
problem there is that your control points need not be coplanar - or even 
form a regular grid!)



More information about the Haskell-Cafe mailing list