Improve transparency handling while plotting.

Only SVG can actually handle transparency, but we should at least mimic
the color value of other transparent fills by blending with a (presumed)
white paper.

Fixes https://gitlab.com/kicad/code/kicad/issues/11304
This commit is contained in:
Jeff Young
2022-04-08 11:40:53 +01:00
parent 702623ef87
commit 079d4a603a
4 changed files with 43 additions and 15 deletions
+11 -1
View File
@@ -159,9 +159,19 @@ void PDF_PLOTTER::SetCurrentLineWidth( int aWidth, void* aData )
}
void PDF_PLOTTER::emitSetRGBColor( double r, double g, double b )
void PDF_PLOTTER::emitSetRGBColor( double r, double g, double b, double a )
{
wxASSERT( workFile );
// PDF treats all colors as opaque, so the best we can do with alpha is generate an
// appropriate blended color assuming white paper.
if( a < 1.0 )
{
r = ( r * a ) + ( 1 - a );
g = ( g * a ) + ( 1 - a );
b = ( b * a ) + ( 1 - a );
}
fprintf( workFile, "%g %g %g rg %g %g %g RG\n", r, g, b, r, g, b );
}