2009-08-16

PDF Generation, Continued [SNEAK PEEK]

I have almost everything functional again under the PdfSharp code. The time consuming bit is that I was using GDI+ TexturedBrushes for a couple of things and PdfSharp (wisely) doesn't provide this, so you have to implement this manually. This actually ended up simplifying the code in several places. The only gotcha is that I was using it in a somewhat complicated way for rendering pseudo-random stars within the galactic arms at certain scales.

The old algorithm went like this:

if (inside charted space)
draw a bunch of pseudo-random stars on the tile
else if (inside the galactic bounds)
construct a tile-sized bitmap
draw a bunch of pseudo-random stars on the bitmap
load a path describing the galactic arms
on the tile, fill the path using the bitmap as a brush

The new code looks like this:

if (inside charted space)
draw a bunch of pseudo-random stars on the tile
else if (inside the galactic bounds)
load a path describing the galactic arms
use the path as a "clipping" region
draw a bunch of pseudo-random stars on the tile

Simpler, huh? Well, yes, but it turns out that (1) it's a whopping huge path with lots of curves and segments (and I reduced it as much as I could), (2) bitmap-based clipping is heavily optimized, and (3) it's a single clip against a region, rather than once per star.

After pondering the importance of this (i.e. not very) I decided to simply ditch the pseudo-random stars away from charted space, and turn on the pretty galaxy image instead if you zoom out.

So... I'm pretty close to flipping the switch on this to make it live, but want to double check all of the changes first. But to whet your appetites, here are few more previews:

Spinward Marches - Eye-Candy - this one is a bit big (1MB) due to all the images
Charted Space

Enjoy! Ω

1 comment:

donm61873 said...

Positively beautiful.

Now, does it work with the white background//black lines selection?

I need to show this to Marc.