Sharpie / RTikZDevice

A R package for producing graphics output as PGF/TikZ code for use in TeX documents.
32 stars 36 forks source link

Don't emit any draw commands for fully transparent fill #46

Closed zackw closed 12 years ago

zackw commented 12 years ago

With the default bg="transparent", we get this at the beginning of every tikzDevice picture:

\fill[color=fillColor,fill opacity=0.00,] (0,0) rectangle (width, height);

This command's only effect is to bulk up the generated PDF. It should not be emitted at all. In general, \fill[...,fill opacity=0,...] should never be generated. A closely related phenomenon is

\draw[fill=fillColor, draw opacity=0.00,] ... ;

which should be optimized to

\fill[color=fillColor] ...;

(And even these are only special cases of the general observation that {fill/draw} opacity=0 and {fill/draw} opacity=1 should never appear in the generated drawing.)

zackw commented 12 years ago

I should add that this is not just an optimization; if you don't ever mention opacity, PGF does not attempt to generate transparency (/CA, /ca extended graphics state) in the PDF. Transparency sometimes causes problems downstream; worse, xetex seems to produce an invalid PDF when transparency is in use.

Sharpie commented 12 years ago

I just committed a refactor of the style output routines. Non-operations such as drawing fully transparent fills or lines should be avoided in most cases.

These changes have been released as part of build 0.6.2-39-7e6ec32. Compiled packages should be available from R-Forge within 48 hours.

zackw commented 12 years ago

Awesome! Thanks for quick fix.