| 1911 | } |
| 1912 | } |
| 1913 | void prepareGradientSource( const svg::Node &node, const svg::Paint &paint, cairo::Gradient &grad, float opacity ) { |
| 1914 | if( paint.useObjectBoundingBox() ) { |
| 1915 | Rectf bb = node.getBoundingBox(); |
| 1916 | cairo::Matrix m; m.initIdentity(); |
| 1917 | float invWidth = ( bb.getWidth() != 0 ) ? ( 1 / bb.getWidth() ) : 0; |
| 1918 | float invHeight = ( bb.getHeight() != 0 ) ? ( 1 / bb.getHeight() ) : 0; |
| 1919 | m.scale( invWidth, invHeight ); |
| 1920 | m.translate( -bb.x1, -bb.y1 ); |
| 1921 | if( paint.specifiesTransform() ) { |
| 1922 | m *= cairo::Matrix( paint.getTransform() ); |
| 1923 | } |
| 1924 | grad.setMatrix( m ); |
| 1925 | } |
| 1926 | else if( paint.specifiesTransform() ) { |
| 1927 | cairo::Matrix m2( paint.getTransform() ); |
| 1928 | m2.invert(); |
| 1929 | grad.setMatrix( m2 ); |
| 1930 | } |
| 1931 | for( size_t s = 0; s < paint.getNumColors(); ++s ) { |
| 1932 | ColorA color = paint.getColor( s ); |
| 1933 | color.a *= opacity; |
| 1934 | grad.addColorStop( paint.getOffset( s ), color ); |
| 1935 | } |
| 1936 | mCtx.setSource( grad ); |
| 1937 | } |
| 1938 | |
| 1939 | void strokeAndFill( const svg::Node &node ) { |
| 1940 | if( prepareSourceFill( node ) ) { |
nothing calls this directly
no test coverage detected