MCPcopy Create free account
hub / github.com/cinder/Cinder / prepareGradientSource

Method prepareGradientSource

blocks/Cairo/src/Cairo.cpp:1913–1937  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 ) ) {

Callers

nothing calls this directly

Calls 11

MatrixClass · 0.85
initIdentityMethod · 0.80
setMatrixMethod · 0.80
invertMethod · 0.80
addColorStopMethod · 0.80
getWidthMethod · 0.45
getHeightMethod · 0.45
scaleMethod · 0.45
translateMethod · 0.45
getOffsetMethod · 0.45
setSourceMethod · 0.45

Tested by

no test coverage detected