Article: Functional image processing in D

Rikki Cattermole alphaglosined at gmail.com
Fri Mar 21 20:52:52 PDT 2014


On Friday, 21 March 2014 at 13:54:25 UTC, Vladimir Panteleev 
wrote:
> On Friday, 21 March 2014 at 12:27:57 UTC, Rikki Cattermole 
> wrote:
>> On Friday, 21 March 2014 at 11:04:58 UTC, Vladimir Panteleev 
>> wrote:
>>> http://blog.thecybershadow.net/2014/03/21/functional-image-processing-in-d/
>>>
>>> Some highlights from a recent overhaul of the graphics 
>>> package from my D library. It makes use of a number of 
>>> D-specific language features, so I've tried to make the 
>>> article accessible to people new to D as well.
>>
>> Are you planning on adding a font rasterizer
>
> Parsing vector font files is a big undertaking. I'd likely use 
> a text rendering library, such as FreeType. Hardcoding a small 
> bitmap font for ASCII only is also a possibility.

Yeah it is quite a big one. But it may be well worth it to have 
it generate code at CTFE per font. Would be more efficient 
probably.

>> and can it work at CTFE?
>
> This program almost works:
>
> string drawSmiley()
> {
> 	import std.range;
> 	import std.math;
>
> 	import ae.utils.graphics.draw;
> 	import ae.utils.graphics.image;
>
> 	auto smiley = Image!char(20, 20);
> 	smiley.fill(' ');
> 	smiley.fillCircle(10, 10, 10, '#');
> 	smiley.fillCircle( 6, 6, 2, ' ');
> 	smiley.fillCircle(14, 6, 2, ' ');
> 	smiley.fillSector(10, 10, 6, 8, 0, PI, ' ');
>
> 	return smiley.h.iota.map!(y => 
> smiley.scanline(y)).join("\n").idup;
> }
>
> pragma(msg, drawSmiley);
>
> "almost" because fillSector calls atan2, which doesn't work in 
> CTFE. :(
>
> (And yeah, I totally did just declare an image with a

Yeah I've noticed that some of phobos wasn't really designed with 
CTFE in mind *grumbles*. Maybe one day I'll look into getting 
that sorted out.
> colorspace of "char".)



More information about the Digitalmars-d-announce mailing list