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.

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 colorspace of "char".)

Reply via email to