Пример #1
0
gl::Texture renderCairoToTexture( svg::DocRef doc )
{
	cairo::SurfaceImage srf;
	if( doc->getWidth() && doc->getHeight() )
		srf = cairo::SurfaceImage( doc->getWidth(), doc->getHeight(), true );
	else
		srf = cairo::SurfaceImage( 640, 480, true );
	cairo::Context ctx( srf );

	ctx.render( *doc );
	srf.flush();
	
	return gl::Texture( srf.getSurface() );
}
Пример #2
0
Surface renderCairo( svg::DocRef doc, const svg::RenderVisitor &visitor )
{
    cairo::SurfaceImage srf;
    if( doc->getWidth() && doc->getHeight() )
        srf = cairo::SurfaceImage( doc->getWidth(), doc->getHeight(), true );
    else
        srf = cairo::SurfaceImage( 640, 480, true );
    cairo::Context ctx( srf );

    ctx.setSourceRgb( 1, 1, 1 );
    ctx.paint();
    ctx.render( *doc, visitor );
    srf.flush();
    Surface result = srf.getSurface();
    return srf.getSurface();
}
Пример #3
0
void AnimatedRevealApp::update()
{
    if( ( ! mDoc ) || mDone )
        return;

    // we'll stop drawing filled after we've drawn new pixels that are 1% of the size of the image
    size_t imageSize, minArea;
    if( mDoc->getWidth() && mDoc->getHeight() )
        imageSize = mDoc->getWidth() * mDoc->getHeight();
    else
        imageSize = 640 * 480;
    minArea = 1 + imageSize * 0.01f;

    Surface frame = renderCairo( mDoc, SlowFillVisitor( mMinRenderElement, minArea, &mMinRenderElement, &mDone ) );
#if defined( RECORD_MOVIE )
    mMovie.addFrame( frame );
    if( mDone ) {
        mMovie.addFrame( frame ); // otherwise we seem to lose the last frame
        mMovie.finish();
    }
#endif
    mTex = gl::Texture::create( frame );
}
Пример #4
0
void AnimatedRevealApp::load( const fs::path &path )
{
    mMinRenderElement = 0;
    try {
        if( path.extension() == ".svgz" ) // compressed
            mDoc = svg::Doc::createFromSvgz( loadFile( path ) );
        else
            mDoc = svg::Doc::create( loadFile( path ) );

        mDone = false;
#if defined( RECORD_MOVIE )
        mMovie = qtime::MovieWriter( fs::path( getHomeDirectory() + "AnimatedReveal.mov" ), mDoc->getWidth(), mDoc->getHeight() );
#endif
    }
    catch( ci::Exception &exc ) {
        console() << "failed to load doc, what: " << exc.what() << endl;
    }
}