My blog has been moved to

Sunday, July 09, 2006

Beauty is in the smoothness of the colors

In the recent days (see also the last progress), I have implemented support for two important things for libwpg: object transformation and gradient.

Object transformation is necessary to have rotated or scaled objects. And most important is for translated objects. In Corel Presentations, when you copy an object and move the copy, the two still shares the same data but have different transformation matrix. Thus, in order to have all objects in proper location, transformation support is necessary.

Another interesting bit is gradient fill. This presents some challenge as the documentation does not say anything except the data structure, and the gradient concept in WPG does not actually fit into SVG model. After wasting many sheets of paper and scribbling lots of (mostly wrong) equations, I found the solution which may match WPG's gradient with SVG. So far it works with linear gradient.

In the screenshot below (click for larger version), you can see the perfect conversion of the gradients. Left side: WordPerfect Office (inside emulator) shows windmill.wpg. Right side: Karbon14 opens windmill.svg, which is windmill.wpg converted to SVG using libwpg's wpg2svg.

Note 1: there are still rendering problem as I have not yet coded proper evenodd fill rule with grouped polygons.

Note 2: Karbon here is just for illustration purpose. Inkscape (or other vector drawing programs which support SVG) works also flawlessly.


Anonymous said...

Wonderful hacking Ariya! It'd be great to finally have libwpd import images correctly utilizing libwpg! Thanks! - uwog

Smokey Ardisson said...

Lovely! I especially enjoy the fact that the SVG looks better (smoother) than the original!

(P.S. It would be nice if there were a link somewhere near the verification box here telling you that the word won't display unless you allow cookies from; maybe you can't control that, though?)